2

嵌套选项卡示例

我正在尝试将文本输入到编辑文本中,但获取显示关键事件的 Logcat 信息,例如 KeyUp 。

protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.datacard_activity, null);
    this.setContentView(viewToLoad); 

从其他活动加载此活动

  //   Datacard Tab
Bundle b3=new Bundle();
b3.putSerializable("objCommonBean",objCommonBean);
Intent intent3 = new Intent().setClass(RechargeNowActivity.this, DatacardActivity.class);
intent3.putExtras(b3);
transactionDatespec = tabHost.newTabSpec("").setIndicator("Data Card",null)
              .setContent(intent3);  
tabHost.addTab(transactionDatespec);

tabHost.addTab(transactionDatespec);

   final int height = 45;
   for(i=0;i<tabHost.getTabWidget().getChildCount();i++) 
   { 
       TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); //Unselected Tabs
       tv.setTextColor(Color.parseColor("#ffffff"));
       tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = height;
   }
   getTabHost().getTabWidget().getChildAt(0).setBackgroundColor(Color.BLACK);
   getTabHost().getTabWidget().getChildAt(1).setBackgroundColor(Color.TRANSPARENT);
   getTabHost().getTabWidget().getChildAt(2).setBackgroundColor(Color.TRANSPARENT);

       tabHost.setCurrentTab(0);



tabHost.setOnTabChangedListener(new OnTabChangeListener(){
    @Override
    public void onTabChanged(String tabId) {
        // TODO Auto-generated method stub
         for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
            {
               tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.TRANSPARENT); //unselected
            }
            tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()).setBackgroundColor(Color.BLACK); // selected
    }
});

}

4

0 回答 0