Android键盘出现的TabBar后 [英] Android Keyboard appear after Tabbar

查看:244
本文介绍了Android键盘出现的TabBar后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的主屏幕四个选项卡,其中一个需要用户输入,
我有两个问题,一个是在打开的选项卡,然后活动Android键盘自动开启
而另一个问题是键盘的TabBar之后到来。

我已经添加了的android:windowSoftInputMode =adjustPan在我的menifetch文件

我分享我的code

我createchallan.xml code

 <?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直><的TextView
    机器人:ID =@ + ID /搜索
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentLeft =真
    机器人:layout_alignParentTop =真
    机器人:layout_marginLeft =10dp
    机器人:layout_marginTop =38dp
    机器人:文字=搜索/><的EditText
    机器人:ID =@ + ID / editText1
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignBaseline =@ + ID /搜索
    机器人:layout_alignBottom =@ + ID /搜索
    机器人:layout_toRightOf =@ + ID /搜索
    机器人:背景=@机器人:可绘制/ editbox_background
    机器人:layout_marginLeft =2DIP    机器人:单线=真
    机器人:EMS =5>    < requestFocus的机器人:layout_width =WRAP_CONTENT/>< /&的EditText GT;
<复选框
    机器人:ID =@ + ID /审查
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignBottom =@ + ID /搜索
    机器人:layout_alignParentRight =真
    机器人:layout_marginTop =6DIP
     机器人:layout_alignBaseline =@ + ID /搜索
    机器人:文字=审议项目/>< RelativeLayout的
     机器人:ID =@ + ID /头
    机器人:layout_marginTop =10dip
    机器人:layout_below =@ + ID /审查
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:背景=#E5E4E2
 机器人:方向=横向><的TextView
    机器人:ID =@ + ID / txtItem code
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:文字=项目code
    机器人:单线=真    机器人:layout_marginLeft =3dip
    机器人:文字样式=大胆
   /><的TextView
    机器人:ID =@ + ID / txtItem
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT    机器人:layout_marginLeft =23dp
    机器人:layout_toRightOf =@ + ID / txtItem code
    机器人:文字样式=大胆
    机器人:文字=项目/> <的TextView
    机器人:ID =@ + ID / txtItem
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_marginRight =14dip
     机器人:layout_alignParentRight =真
    机器人:layout_alignParentTop =真
    机器人:文字样式=大胆
    机器人:文字=数量/>< / RelativeLayout的><的LinearLayout
    机器人:ID =@ + ID / listlayout
    机器人:layout_width =FILL_PARENT    机器人:layout_height =WRAP_CONTENT
     机器人:layout_below =@ + ID /头
      机器人:layout_above =@ + ID / lastbutton>    < ListView控件
    机器人:ID =@ + ID / createlist
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
   机器人:可点击=真
    机器人:cacheColorHint =#00000000
    机器人:分=#adb8c2
    机器人:dividerHeight =1DP
    机器人:scrollingCache =假
    机器人:smoothScrollbar =真   >< /&的ListView GT;
< / LinearLayout中> < RelativeLayout的
      机器人:layout_alignParentBottom =真     机器人:ID =@ + ID / lastbutton    机器人:layout_marginBottom =8DIP
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT     机器人:方向=横向>
     <按钮
        机器人:ID =@ + ID / createcancel        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
       机器人:layout_marginRight =10dp
        机器人:layout_alignParentTop =真
        机器人:layout_toLeftOf =@ + ID / createsavedraft
          机器人:背景=@绘制/ roundedbutton
        机器人:文字=取消/>
     <按钮
        机器人:ID =@ + ID / createsavedraft        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
       机器人:layout_marginRight =10dp
        机器人:layout_alignParentTop =真
        机器人:layout_toLeftOf =@ + ID / creatapprove
          机器人:背景=@绘制/ roundedbutton
        机器人:文本=保存草稿/>     <按钮
        机器人:ID =@ + ID / creatapprove        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignParentRight =真        机器人:layout_alignParentTop =真
        机器人:背景=@绘制/ roundedbutton
        机器人:文字=批准/>     < / RelativeLayout的>

我的自定义XML create_list_item.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
 机器人:方向=横向><的TextView
    机器人:ID =@ + ID / txtItem code
    机器人:layout_width =70dip
    机器人:layout_height =WRAP_CONTENT
    机器人:文字=323232
    机器人:单线=真
    机器人:layout_marginTop =9dip
    机器人:layout_marginLeft =5dip
    机器人:文字样式=大胆
     机器人:可聚焦=假
    机器人:focusableInTouchMode =假
   /><的TextView
    机器人:ID =@ + ID / txtItem
    机器人:layout_width =70dip
    机器人:layout_height =WRAP_CONTENT
   机器人:layout_marginTop =9dip
    机器人:layout_marginLeft =25dp
    机器人:layout_toRightOf =@ + ID / txtItem code
     机器人:layout_alignBaseline =@ + ID / txtItem code
    机器人:文字=5456455565456
     机器人:可聚焦=假
      机器人:focusableInTouchMode =FALSE/> <的EditText
     机器人:ID =@ + ID / editcreateQuantity
     机器人:layout_width =70dp
     机器人:layout_height =WRAP_CONTENT
     机器人:layout_alignParentRight =真
     机器人:layout_alignParentTop =真
     机器人:背景=@机器人:可绘制/ editbox_background
     机器人:EMS =10
     安卓的inputType =数字
     机器人:layout_marginRight =5dip
      机器人:layout_alignBaseline =@ + ID / txtItem code
机器人:可聚焦=真
     机器人:单线=真正的>
< /&的EditText GT;< / RelativeLayout的>

我的Java code

 公共类CreateChallan延伸活动{
 ListView的lstCreate; 的String [] strmainItem code;
 的String [] strItem;
 的String [] strQuantity;
 上下文的背景下=这;@覆盖
保护无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.createchallan);
    lstCreate =(ListView控件)findViewById(R.id.createlist);
    lstCreate.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);    strmainItem code =新的String [] {55555551,255555,355555,455555,555555};    strItem =新的String [] {A,B,C,D,F};    strQuantity =新的String [] {100,200,30,400,500};    CreateAdapter适配器=新CreateAdapter(这一点,strmainItem code,strItem,strQuantity);    lstCreate.setAdapter(适配器);    lstCreate.setOnItemClickListener(新AdapterView.OnItemClickListener(){        @覆盖
        公共无效onItemClick(适配器视图<>母公司,观景,
                                INT位置1,长ID){
            // TODO自动生成方法存根            Toast.makeText(背景下,位置,Toast.LENGTH_LONG).show();        }
    });
}//创建列表适配器类CreateAdapter扩展ArrayAdapter<串GT;
 {
    TextView的txtIte code,txtItem;
    的EditText editQuantity;
    的String [] strIte code;
    的String [] strItem;
    的String [] strQuantity;
    上下文语境;    CreateAdapter(上下文的背景下,字符串[] strItem code,的String [] strItem,字符串[] strQauntity)
    {
            超(背景下,R.layout.create_list_item,R.id.txtItem code,strItem code);
        this.context =背景;
        this.strIte code = strItem code;
        this.strItem = strItem;
        this.strQuantity = strQauntity;
    }
     公共查看getView(INT位置,查看convertView,父母的ViewGroup){
         LayoutInflater mInflater =(LayoutInflater)context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
         查看排;
         行= mInflater.inflate(R.layout.create_list_item,父母,假);         txtIte code =(TextView中)row.findViewById(R.id.txtItem code);
         txtItem =(TextView中)row.findViewById(R.id.txtItem);
         editQuantity =(EditText上)row.findViewById(R.id.editcreateQuantity);
         editQuantity.setSelected(假);
         txtIte code.setText(strIte code [位置]);
         txtItem.setText(strItem [位置]);
        editQuantity.setText(strQuantity [位置]);         txtIte code.setOnClickListener(新OnClickListener(){            @覆盖
            公共无效的onClick(视图v){
                // TODO自动生成方法存根
                Toast.makeText(背景下,点击,Toast.LENGTH_LONG).show();
            }
        });         返回行;
     }
 }
  }


解决方案

下面你code表现在TabHostActivity或制表符父活动。

 的android:windowSoftInputMode =adjustPan

I have four tabs in my home screen and one of them takes user input, I have a two problem one is when open tab activity then android keyboard automatically open and another problem is keyboard coming after tabbar.

I already added android:windowSoftInputMode="adjustPan" in my menifetch file

I Share My code

My createchallan.xml code

<?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>

my custom xml create_list_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>

My java code

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;


     }
 }


  }

解决方案

below code on you manifest in TabHostActivity or tab parent activity..

 android:windowSoftInputMode="adjustPan"

这篇关于Android键盘出现的TabBar后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆