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 832419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:21:36+00:00 2026-05-15T04:21:36+00:00

i made a small test app with 2 screens. the first screen contains an

  • 0

i made a small test app with 2 screens. the first screen contains an EditText and a Button. The second screen is just a simple ListActivity showing 3 static items.
The ListActivity is started when the user clicks the Button on the first screen or when the enter key was hit in the TextEdit. The weird thing is if the ListActivity was started by pressing the enter key in the EditText view, then the first list item is selected right after the startup. if it was started by hitting the button, everything is normal – no list item is selected.

that’s the code that starts the ListActivity.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.startup);

    final Button b = (Button)findViewById(R.id.but);
    b.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startList();
        }
    });

    final EditText t = (EditText)findViewById(R.id.in_text);
    t.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            startList();
            return true;
        }
    });
}

public void startList(){
    Intent i = new Intent(this, TestList.class);
    startActivity(i);
}

and this is the code of the ListActivity

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list);

        inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        String[] str = {"a", "b", "c"};

        ListAdapter adapter = new ArrayAdapter<String>(this, R.layout.list_item, str){
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View row = 
                        null == convertView ? 
                        inflater.inflate(R.layout.list_item, null) : 
                        convertView;

                String s = getItem(position);
                TextView tvid = (TextView)row.findViewById(R.id.word_suggestion_item_text);
                tvid.setText(s);

                return row;
            }
        };

        setListAdapter(adapter);
    }

any ideas why that happens?

Simon

  • 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-05-15T04:21:37+00:00Added an answer on May 15, 2026 at 4:21 am

    The weird thing is if the ListActivity
    was started by pressing the enter key
    in the EditText view, then the first
    list item is selected right after the
    startup. if it was started by hitting
    the button, everything is normal – no
    list item is selected.

    If they use hardware input (e.g., Enter key) immediately before you start the ListActivity, they will not be in touch mode. If they use the touchscreen immediately before you start the ListActivity, they will be in touch mode. The selection highlight is not shown in touch mode. See here for more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a small test app with a button and a UISlider. Touching
I am just starting to learn Core Audio and made a simple test application
I've made up a small test app to demo the issue I'm trying to
I've made a small game that uses level, and level is just a int
I have a small app I've made that I intend to make available on
Hey guys I'm new to rails. I made this small test code for learning
I made a small test application that uses the GPS module. To test it,
I made a small test program that multiplies and adds 10 million numbers. With
I made small program to divide large pictures and take part of them. When
I made a small project where i try to change the name from edit

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.