android - Soft key not appear while tapping on EditText which is inside listView and listView is in AleartBox -


in application customize alear box there. in alert box there customize listview in 1 textview , 1 edittext there. every thing work fine , alert box coming on screen perfectly.

but when tap on edit text fill characters edit text, android softkey on appearing. therefore not able insert , data edit text.

my code:-

activity_main.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" >  <button     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:text="add population"     android:onclick="getpopulation" /> </relativelayout> 

alert_box.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >  <listview     android:id="@+id/lview"     android:layout_width="match_parent"     android:layout_height="0dp"     android:layout_weight="1"     tools:listitem="@layout/list_view_resourse" > </listview>  <linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:orientation="horizontal" >      <button         android:id="@+id/add"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:text="add" />      <button         android:id="@+id/cancel"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="1"         android:text="cancel" /> </linearlayout> </linearlayout> 

list_view_resourse.xml

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

<textview     android:id="@+id/district"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_weight="2"     android:textcolor="#000000"     android:textstyle="bold" /> <edittext      android:id="@+id/population"     android:layout_width="0dp"     android:layout_weight="1"     android:layout_height="wrap_content" /> </linearlayout> 

mainactivity

package com.exmp;  import java.util.arraylist;  import android.os.bundle; import android.app.activity; import android.app.alertdialog; import android.view.layoutinflater; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.arrayadapter; import android.widget.button; import android.widget.listview;  public class mainactivity extends activity implements onclicklistener{ private arrayadapter<disrict> adapter; private arraylist<disrict> disricts; private listview lview; private button add, cancel; private alertdialog dialog;   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);  }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; }  private void getpopulation() {     layoutinflater inflater = getlayoutinflater();     view view = inflater.inflate(r.layout.alert_box, null);     lview = (listview) view.findviewbyid(r.id.lview);     add = (button) view.findviewbyid(r.id.add);     cancel = (button) view.findviewbyid(r.id.cancel);     disricts = new arraylist<disrict>();     disricts.add(new disrict(1, "bangalore", 45.22));     disricts.add(new disrict(1, "gulbarga", 22.22));     adapter = new districtadapter(mainactivity.this, r.layout.list_view_resourse, disricts);     lview.setadapter(adapter);      cancel.setonclicklistener(this);      alertdialog.builder alert = new alertdialog.builder(this);     alert.settitle("population");     alert.setview(view);     alert.setcancelable(false);      dialog = alert.create();     dialog.show();  }  public void getpopulation(view v){     getpopulation(); }  @override public void onclick(view v) {     switch (v.getid()) {     case r.id.add:          break;      case r.id.cancel:         dialog.dismiss();         break;     } } } 

disrict

package com.exmp;  public class disrict { private int id; private string strdistrict; private double population; public disrict(int id, string strdistrict, double population) {     super();     this.id = id;     this.strdistrict = strdistrict;     this.population = population; } public int getid() {     return id; } public string getstrdistrict() {     return strdistrict; } public double getpopulation() {     return population; }  @override public string tostring() {     return strdistrict; } } 

districtadapter

package com.exmp;  import java.util.arraylist;  import android.content.context; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.button; import android.widget.spinner; import android.widget.textview;  public class districtadapter extends arrayadapter<disrict> {  private final context context; private final int rowresourceid; private final arraylist<disrict> disricts;  public districtadapter(context context, int resource,         arraylist<disrict> disricts) {     super(context, resource, disricts);      this.context = context;     this.rowresourceid = resource;     this.disricts = disricts; }  @override public view getview(int position, view convertview, viewgroup parent) {     spinner spinnerpaymenttype = null;     layoutinflater inflater = (layoutinflater) context             .getsystemservice(context.layout_inflater_service);     view rowview = inflater.inflate(rowresourceid, parent, false);     textview textview  = (textview) rowview.findviewbyid(r.id.district);     textview.settext(disricts.get(position).getstrdistrict());      return rowview; } } 

try code in listview

<listview android:id="@android:id/list"  android:layout_height="fill_parent"  android:layout_width="fill_parent" android:descendantfocusability="beforedescendants" /> 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -