2014-03-30 62 views
1

我的四個選項卡在我的主屏幕,其中一個需要用戶輸入, 我有一個兩個問題一個是當打開選項卡活動,然後Android鍵盤自動打開 和另一個問題是鍵盤後, 。安卓鍵盤出現後Tabbar

我已經在我的menifetch文件添加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 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> 

我的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; 


    } 
} 


    } 
+0

你在使用TabHost嗎? –

+0

你是我使用TabHost – Kuldeep

回答

1

下面你的代碼清單中TabHostActivity或標籤父活動..

android:windowSoftInputMode="adjustPan" 
+0

發佈你的清單文件.. –

+1

非常感謝你ü保存我的很多時間 – Kuldeep

1

嗨嘗試下面的代碼對你表現的活動

android:windowSoftInputMode="adjustPan" 

希望這會工作,感謝

+0

已經添加,但不能正常工作 – Kuldeep