Skip to main content

EditText Not working in Custom ListView in Android

OnClick EditText Looses Focuse in Custom ListView In Android



If you set up your layout like the one showed above you'll soon have to deal with an annoying problem. For some unknown reason the EditText immediately loses focus, and it's almost impossible to write anything.
Fortunately the solution is quite easy: you just have to add the following lines of code:
in the AndroidManifest.xml file add the following line for the Activity containing the ListView: android:windowSoftInputMode="adjustPan";
in the layout file of the Activity add the following line to your ListView:

1. android:windowSoftInputMode="stateHidden|adjustPan"
2. android:descendantFocusability="beforeDescendants"



<activity        
      android:name=".TestReading"       
      android:windowSoftInputMode="stateHidden|adjustPan"/>
</application> 

<ListView    
      android:id="@+id/light_list"  
      android:layout_width="match_parent"
      android:layout_height="wrap_content"  
      android:layout_below="@+id/radio_group_roomtype"   
      android:dividerHeight="15.0sp"   
      android:descendantFocusability="beforeDescendants"/>



Comments

Popular posts from this blog

How to align Title at center of ActionBar in Android

How to Align Title At Center of Action Bar in Android                                                                                                                                                @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle("DashBoard"); }   Activity  public void setTitle ( String title ){ getSupportActionBar (). setHomeButtonEnabled ( true ); getSupportActionBar (). setDisplayHomeAsUpEnabled ( true ); TextView textView = new TextView ( this ); textView . set...

Expected a key while parsing a block mapping (Flutter)

Flutter makes use of the Dart packaging system, pub. Via your applications  pubspec.yam l file (or simple pubspec), you can pull down packages from the flutter ecosystem, or the broader dart community. Anyway, i need to add some images to my flutter application, and so had to add an assets section to the pubspec .the default Android Studio generated apps pubspec has a lot of commented out code with explainations about what is going on, e.g # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.io/assets-and-images/#resolution-aware. So I uncommented these lines # assest : - - - #  -  images/a_dot_ham.jpeg with the idea from these comment.  that i would just edit it to suit my particular needs. Once you have edited your  pubspec, you need to click on the "Get dependenc...

Difference Between Pending Intent And Intent in Android

                       Normal Intent       Normal Intent will die as soon as the app being killed.    An Android Intent is an object carrying an intent, i.e a message from one Component to another     Component either inside or outside of the application.Intent can communicate message among     any of the three core Components of an application -- Activities, Services,and BroadcastReceivers.     Two types of Intent in Android   1. Explicit Intent.   2.Implicit Intent  Explicit Intent is an Intent which is used to Call the another component Explicitly in your application  Like :We are calling  Next activity on button click of First activity using Intent Example  // Explicit Intent by specifying its class name Intent i = new Intent ( this , TargetActivity . class ); i . putExtra ( "Key1" , "ABC" ); ...