Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:51:11+00:00 2026-06-09T17:51:11+00:00

Here is my navigationMovement() : protected boolean navigationMovement(int dx, int dy, int status, int

  • 0

Here is my navigationMovement():

protected boolean navigationMovement(int dx, int dy, int status, int time) {

        int focusIndex = getFieldWithFocusIndex();

        while (dy > 0) {
            if (focusIndex >= getFieldCount()) {
                return false;
            } else {
                Field f = getField(focusIndex);
                if (f.isFocusable()) {
                    f.setFocus();
                    dy--;
                }
            }
        }

        while (dy < 0) {
            if (focusIndex < 0) {
                return false;
            } else {
                Field f = getField(focusIndex);

                if (f.isFocusable()) {
                    f.setFocus();
                    dy++;
                }
            }
        }

        while (dx > 0) {
            focusIndex++;

            if (focusIndex >= getFieldCount()) {
                return false;
            } else {
                Field f = getField(focusIndex);

                if (f.isFocusable()) {
                    f.setFocus();
                    dx--;
                }
            }
        }

        while (dx < 0) {
            focusIndex--;

            if (focusIndex < 0) {
                return false;
            } else {
                Field f = getField(focusIndex);

                if (f.isFocusable()) {
                    f.setFocus();
                    dx++;
                }
            }
        }

        return true;
}

This only allows the track wheel to scroll left and right, but I want up, down, left and right.

my layout is this.

It is a 3 rows x 4 columns.

This code is checking getField(0->10), that’s why it cannot from 0 to 4.

I want it to be movable in all directions. How to implement that?

Updated

protected void sublayout(int width, int height) {
        int y = 0;

        Field[] fields = new Field[columnWidths.length];
        int currentColumn = 0;
        int rowHeight = 0;

        for (int i = 0; i < getFieldCount(); i++) {
            fields[currentColumn] = getField(i);
            fields[currentColumn]
                    .setChangeListener(new FieldChangeListener() {
                        public void fieldChanged(Field field, int context) {
                            final int focusIndex = getFieldWithFocusIndex();
                            if (focusIndex == position) {
                                Main.getUiApplication().popScreen(
                                        mainscreen);
                            } else {
                                Main.getUiApplication().popScreen(
                                        mainscreen);
                                Main.getUiApplication().pushScreen(
                                        new Custom_LoadingScreen(1));
                                Main.getUiApplication().invokeLater(
                                        new Runnable() {
                                            public void run() {
                                                if (focusIndex == 0)
                                                    Main.getUiApplication()
                                                            .pushScreen(
                                                                    new Main_AllLatestNews());
                                                else
                                                    Main.getUiApplication()
                                                            .pushScreen(
                                                                    new Main_ParticularCategoryAllNews(
                                                                            catnewsid[focusIndex],
                                                                            focusIndex,
                                                                            cattitle[focusIndex]));
                                            }
                                        }, 1 * 1000, false);
                            }
                        }
                    });
            layoutChild(fields[currentColumn], columnWidths[currentColumn],
                    height - y);

            if (fields[currentColumn].getHeight() > rowHeight) {
                rowHeight = fields[currentColumn].getHeight() + 10;
            }

            currentColumn++;

            if ((currentColumn == columnWidths.length)
                    || (i == (getFieldCount() - 1))) {
                int x = 0;

                if (this.allRowHeight >= 0) {
                    rowHeight = this.allRowHeight;
                }

                for (int c = 0; c < currentColumn; c++) {
                    long fieldStyle = fields[c].getStyle();
                    int fieldXOffset = 0;
                    long fieldHalign = fieldStyle & Field.FIELD_HALIGN_MASK;

                    if (fieldHalign == Field.FIELD_RIGHT) {
                        fieldXOffset = columnWidths[c]
                                - fields[c].getWidth();
                    } else if (fieldHalign == Field.FIELD_HCENTER) {
                        fieldXOffset = (columnWidths[c] - fields[c]
                                .getWidth()) / 2;
                    }

                    int fieldYOffset = 0;
                    long fieldValign = fieldStyle & Field.FIELD_VALIGN_MASK;

                    if (fieldValign == Field.FIELD_BOTTOM) {
                        fieldYOffset = rowHeight - fields[c].getHeight();
                    } else if (fieldValign == Field.FIELD_VCENTER) {
                        fieldYOffset = (rowHeight - fields[c].getHeight()) / 2;
                    }

                    setPositionChild(fields[c], x + fieldXOffset, y
                            + fieldYOffset);
                    x += columnWidths[c];
                }

                currentColumn = 0;
                y += rowHeight;
            }

            if (y >= height) {
                break;
            }
        }

        int totalWidth = 0;

        for (int i = 0; i < columnWidths.length; i++) {
            totalWidth += columnWidths[i];
        }

        if (position > -1) {
            Field f = getField(position);
            f.setFocus();
        }

        setExtent(totalWidth, Math.min(y, height));
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:51:12+00:00Added an answer on June 9, 2026 at 5:51 pm

    I just find the solution which is each move +/- column size

    while (dy > 0) {
                if (focusIndex + columnwidth.length >= getFieldCount()) {
                    return false;
                } else {
                    Field f = getField(focusIndex + columnwidth.length);
                    if (f.isFocusable()) {
                        f.setFocus();
                        dy--;
                    }
                }
            }
    
    while (dy < 0) {
                if (focusIndex - columnwidth.length < 0) {
                    return false;
                } else {
                    Field f = getField(focusIndex - columnwidth.length);
    
                    if (f.isFocusable()) {
                        f.setFocus();
                        dy++;
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is my code to solve equation: fx=function(x){ x^3-x-3} solve=function(a,b,eps){ if(abs(fx(a))<0.00001) return(list(root=a,fun=fx(a))) else if(abs(fx(b))<0.00001)
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here I am trying to change the value of the following check box while
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here is a code snippet I was working with: int *a; int p =
Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change
here's my code private void make_Book(int x, int y, string name) { #region Creating
Here is my Default.aspx <%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=_Default ValidateRequest=false %> <html> <head
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.