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

  • Home
  • SEARCH
  • 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 7672639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:19:56+00:00 2026-05-31T16:19:56+00:00

I’m struggeling with an issue that really drives my crazy. I found comparable issues

  • 0

I’m struggeling with an issue that really drives my crazy. I found comparable issues in the forums, but they all are not quite the same like this one. So I hope that someone has a brilliant idea how I could solve this. Or tell me what I’m doing wrong. 😉

The setup:

I have a ListView. The following XML code represents the child elements:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" 
    android:layout_width    = "match_parent"
    android:layout_height   = "wrap_content"
    android:id              = "@+id/container">

    <EditText android:id            = "@+id/child"
              android:layout_width  = "300dp"
              android:layout_height = "wrap_content" />

</LinearLayout>

it is a LinearLayout that in turn has an EditText view inside. The following code adds one child to the list. Since the EditText view is smaller than the LinearLayout where it is embedded, for testing I’ve attached a click listener to the empty space of this (first) child’s LinearLayout. When clicking on this child a second child is inserted into the ListView:

public class Keyboard_Bug extends ListActivity
{
    static BugAdapter mAdapter;
    static String [] mNameArray = new String [2];
    static int mCount; 

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mNameArray[0] = "Entry 1";
        mCount = 1;
        mAdapter = new BugAdapter(this);
        setListAdapter(mAdapter);
    }

    public static class BugAdapter extends BaseAdapter
    {
        final LayoutInflater mInflater;
        EditText mView;

        public BugAdapter(Context context)     { mInflater = LayoutInflater.from ( context );   }
        public int  getCount  ()               { return mCount  ; }
        public long getItemId ( int position ) { return position; }
        public Object getItem ( int position ) { return mNameArray[position]; }

        public View getView( int position, View convertView, ViewGroup parent )
        {
            if ( convertView == null )
                convertView = mInflater.inflate(R.layout.child, parent, false);

            mView = (EditText) convertView.findViewById(R.id.child);
            mView.setText(mNameArray[position]);

            // Get focus 1
//          if ( mNameArray[position].equals("Entry 1") )
//              mView.requestFocus();

            // Get focus 2
            if ( mNameArray[position].equals("Entry 2") )
                mView.requestFocus();

            LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.container);

            ll.setOnClickListener(new View.OnClickListener()     {          
                public void onClick(View v) {
                    mNameArray[mCount] = "Entry 2";
                    mCount++;
                    mAdapter.notifyDataSetChanged();
            }});

            return  convertView;
        }   
    }
}

When I use the (commented out) code section with the comment “Get focus 1”, everything works perfect. “Entry 1” gets the focus and the keyboard pops up.

The issue:

When the onClick handler now inserts the second child and I use the code section with the comment “Get focus 2”, the second child’s EditText view obtains the focus (that’s fine), but the keyboard does not open. I can also click on the newly created EditText, and even though the cursor is blinking I cannot open the keyboard. The only way is to select the first EditText and then select the second EditText again. Then the keyboard opens.

I tried already:

InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

as posted in different forums, but it didn’t work. The only thing that worked was:

mgr.toggleSoftInput ( 0, 0 );

But this of course is not the right approach, since in case the keyboard is already open, it would then be closed.

I would greatly apreciate any suggestions! Thanks!

Bernd

  • 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-31T16:19:57+00:00Added an answer on May 31, 2026 at 4:19 pm

    Use this code on EditText Click event :

    InputMethodManager m = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      if(m != null){
          m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
       } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am doing a simple coin flipping experiment for class that involves flipping a

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.