Android键盘出现在Tabbar之后
我的主屏幕上有四个选项卡,其中一个接受用户输入, 我有两个问题,一个是当打开选项卡活动时,android键盘会自动打开 另一个问题是键盘在tabbar之后 我已经在我的文件中添加了Android键盘出现在Tabbar之后,android,android-layout,android-tabhost,android-tabs,Android,Android Layout,Android Tabhost,Android Tabs,我的主屏幕上有四个选项卡,其中一个接受用户输入, 我有两个问题,一个是当打开选项卡活动时,android键盘会自动打开 另一个问题是键盘在tabbar之后 我已经在我的文件中添加了android:windowSoftInputMode=“adjustPan” 我分享我的代码 我的createchallan.xml代码 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://sche
android:windowSoftInputMode=“adjustPan”
我分享我的代码
我的createchallan.xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="38dp"
android:text="Search" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/search"
android:layout_alignBottom="@+id/search"
android:layout_toRightOf="@+id/search"
android:background="@android:drawable/editbox_background"
android:layout_marginLeft="2dip"
android:singleLine="true"
android:ems="5" >
<requestFocus android:layout_width="wrap_content" />
</EditText>
<CheckBox
android:id="@+id/review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/search"
android:layout_alignParentRight="true"
android:layout_marginTop="6dip"
android:layout_alignBaseline="@+id/search"
android:text="Review Item" />
<RelativeLayout
android:id="@+id/header"
android:layout_marginTop="10dip"
android:layout_below="@+id/review"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E5E4E2"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtItemcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Code"
android:singleLine="true"
android:layout_marginLeft="3dip"
android:textStyle="bold"
/>
<TextView
android:id="@+id/txtItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_toRightOf="@+id/txtItemcode"
android:textStyle="bold"
android:text="Item" />
<TextView
android:id="@+id/txtItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="14dip"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:textStyle="bold"
android:text="Quantity" />
</RelativeLayout>
<LinearLayout
android:id="@+id/listlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
android:layout_above="@+id/lastbutton">
<ListView
android:id="@+id/createlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:cacheColorHint="#00000000"
android:divider="#adb8c2"
android:dividerHeight="1dp"
android:scrollingCache="false"
android:smoothScrollbar="true"
>
</ListView>
</LinearLayout>
<RelativeLayout
android:layout_alignParentBottom="true"
android:id="@+id/lastbutton"
android:layout_marginBottom="8dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/createcancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/createsavedraft"
android:background="@drawable/roundedbutton"
android:text=" Cancel " />
<Button
android:id="@+id/createsavedraft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/creatapprove"
android:background="@drawable/roundedbutton"
android:text=" Save Draft " />
<Button
android:id="@+id/creatapprove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@drawable/roundedbutton"
android:text=" Approve " />
</RelativeLayout>
我的自定义xml创建\u列表\u item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/txtItemcode"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:text="323232"
android:singleLine="true"
android:layout_marginTop="9dip"
android:layout_marginLeft="5dip"
android:textStyle="bold"
android:focusable="false"
android:focusableInTouchMode="false"
/>
<TextView
android:id="@+id/txtItem"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:layout_marginTop="9dip"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/txtItemcode"
android:layout_alignBaseline="@+id/txtItemcode"
android:text="5456455565456"
android:focusable="false"
android:focusableInTouchMode="false" />
<EditText
android:id="@+id/editcreateQuantity"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@android:drawable/editbox_background"
android:ems="10"
android:inputType="number"
android:layout_marginRight="5dip"
android:layout_alignBaseline="@+id/txtItemcode"
android:focusable="true"
android:singleLine="true" >
</EditText>
</RelativeLayout>
我的java代码
public class CreateChallan extends Activity {
ListView lstCreate;
String[] strmainItemCode;
String[] strItem;
String[] strQuantity;
Context context=this;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createchallan);
lstCreate= (ListView) findViewById(R.id.createlist);
lstCreate.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
strmainItemCode= new String[]{"55555551","255555","355555","455555","555555"};
strItem =new String[]{"A","B","C","D","F"};
strQuantity =new String[]{"100","200","30","400","500"};
CreateAdapter adapter= new CreateAdapter(this, strmainItemCode, strItem, strQuantity);
lstCreate.setAdapter(adapter);
lstCreate.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position1, long id) {
// TODO Auto-generated method stub
Toast.makeText(context, "Position", Toast.LENGTH_LONG).show();
}
});
}
// Create List Adapter
class CreateAdapter extends ArrayAdapter<String>
{
TextView txtItecode, txtItem;
EditText editQuantity;
String[] strItecode;
String[] strItem;
String[] strQuantity;
Context context;
CreateAdapter(Context context, String[] strItemcode, String[] strItem, String[] strQauntity)
{
super(context,R.layout.create_list_item,R.id.txtItemcode,strItemcode);
this.context= context;
this.strItecode= strItemcode;
this.strItem= strItem;
this.strQuantity= strQauntity;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View row;
row=mInflater.inflate(R.layout.create_list_item, parent,false);
txtItecode= (TextView) row.findViewById(R.id.txtItemcode);
txtItem =(TextView) row.findViewById(R.id.txtItem);
editQuantity = (EditText) row.findViewById(R.id.editcreateQuantity);
editQuantity.setSelected(false);
txtItecode.setText(strItecode[position]);
txtItem.setText(strItem[position]);
editQuantity.setText(strQuantity[position]);
txtItecode.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, "click", Toast.LENGTH_LONG).show();
}
});
return row;
}
}
}
公共类CreateChallan扩展活动{
列表视图创建;
字符串[]strmainItemCode;
弦[]横线;
字符串[]strqutty;
上下文=这个;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.createchallan);
lstCreate=(ListView)findViewById(R.id.createlist);
lstCreate.setChoiceMode(AbsListView.CHOICE\u MODE\u MULTIPLE);
strmainItemCode=新字符串[]{“5555555 1”、“255555”、“355555”、“455555”、“555555”};
strItem=新字符串[]{“A”、“B”、“C”、“D”、“F”};
strQuantity=新字符串[]{“100”、“200”、“30”、“400”、“500”};
CreateAdapter=新的CreateAdapter(this,strmainItemCode,strItem,strQuantity);
lstCreate.setAdapter(适配器);
lstCreate.setOnItemClickListener(新的AdapterView.OnItemClickListener(){
@凌驾
public void onItemClick(AdapterView父级、视图、,
内部位置1,长id){
//TODO自动生成的方法存根
Toast.makeText(上下文,“位置”,Toast.LENGTH_LONG).show();
}
});
}
//创建列表适配器
类CreateAdapter扩展了ArrayAdapter
{
text查看txtItecode,txtItem;
编辑文本编辑数量;
字符串[]strItecode;
弦[]横线;
字符串[]strqutty;
语境;
CreateAdapter(上下文上下文,字符串[]strItemcode,字符串[]strItem,字符串[]strqUnity)
{
super(context,R.layout.create_list_item,R.id.txtItemcode,strItemcode);
this.context=context;
this.strItemcode=strItemcode;
这个。strItem=strItem;
这个.strqounty=strqountity;
}
公共视图getView(int位置、视图转换视图、视图组父视图){
LayoutInflater mInflater=(LayoutInflater)context.getSystemService(Activity.LAYOUT\u INFLATER\u SERVICE);
查看行;
row=mInflater.充气(R.layout.create_list_item,parent,false);
txtItecode=(TextView)row.findViewById(R.id.txtItemcode);
txtItem=(TextView)row.findViewById(R.id.txtItem);
editQuantity=(EditText)row.findViewById(R.id.editcreateQuantity);
editQuantity.setSelected(假);
setText(strItecode[位置]);
txtItem.setText(strItem[位置]);
editQuantity.setText(strQuantity[位置]);
setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
Toast.makeText(上下文“单击”,Toast.LENGTH_LONG.show();
}
});
返回行;
}
}
}
您好,请在您的活动清单上尝试下面的代码
android:windowSoftInputMode="adjustPan"
希望这能起作用,谢谢下面关于您在TabHostActivity或tab parent activity中清单的代码
android:windowSoftInputMode="adjustPan"
你在使用TabHost吗?非常感谢你节省了我很多时间