Android TabActivity,具有基于按钮单击的多个嵌套活动

Android TabActivity,具有基于按钮单击的多个嵌套活动,android,Android,我面临的问题是如何使用嵌套 基于安卓点击按钮的活动 我有三个选项卡:仪表板、车辆搜索和位置搜索。当我 按“位置搜索”选项卡,我将获得编辑文本(输入邮政编码) 和go按钮(当我按下它时,我应该在100英里内得到位置 不同页面(称为位置搜索结果页面)中的邮政编码 我的具体问题是,当我按下go按钮并 在我得到位置之前 我有一个MainActivity类,它扩展了TabActivity并定义了所有 标签 我还有BranchSearchHelper类,它扩展了ActivityGroup public cl

我面临的问题是如何使用嵌套 基于安卓点击按钮的活动

我有三个选项卡:仪表板、车辆搜索和位置搜索。当我 按“位置搜索”选项卡,我将获得编辑文本(输入邮政编码) 和go按钮(当我按下它时,我应该在100英里内得到位置 不同页面(称为位置搜索结果页面)中的邮政编码

我的具体问题是,当我按下go按钮并 在我得到位置之前

我有一个MainActivity类,它扩展了TabActivity并定义了所有 标签

我还有BranchSearchHelper类,它扩展了ActivityGroup

public class BranchSearchHelper extends ActivityGroup
{
     public static BranchSearchHelper branchSearch;
     private ArrayList<View> history;
     @Override
   public void onCreate(Bundle savedInstanceState)
     {
       super.onCreate(savedInstanceState);
       branchSearch = this;
       this.history = new ArrayList<View>();


       View view =
getLocalActivityManager().startActivity("BranchSearch", new
Intent(this,BranchSearch.class)
                 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();

       replaceView(view);
     }

     public void replaceView(View v)
     {
                          // Adds the old one to history
                   history.add(v);
                           // Changes this Groups View to the new
View.
                   setContentView(v);
     }

      public void back()
      {
                    if(history.size() > 0) {
                        history.remove(history.size()-1);

setContentView(history.get(history.size()-1));
                    }
                    else
                    {
                        finish();
                    }
}

               @Override
               public void onBackPressed()
               {

                 BranchSearchHelper.branchSearch.back();
                    return;
                }
}
我总是得到异常抛出的javaNUllPointerexception

View view =
BranchSearchHelper.branchSearch.getLocalActivityManager().startActivity("Locations
Results",i).getDecorView();
因为branchSearch是空的

那么,你能告诉我如何跟踪标签和显示吗 当我按下go按钮时,所有的位置都会显示出来 使应用程序崩溃。(我应该更改代码的哪些部分)

有一个名为LocationSearchResults的类处理
显示所有位置搜索结果

branchSearch=this将使branchSearch成为ActivityGroup。要纠正这个问题,您可以删除它并添加行
branchSearch=view位于onClick声明的底部

public class BranchSearch extends Activity implements OnClickListener
{

     public void onCreate(Bundle savedInstanceState)
     {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.branchsearch);
             Button locSearch = (Button)
findViewById(R.id.btnlocSearch);
             locSearch.setOnClickListener(this);
         }

      public void onClick(View v)
     {
                 // TODO Auto-generated method stub

                 EditText editText = (EditText)
findViewById(R.id.lsearch);

                 Bundle bundle = new Bundle();
                 bundle.putString("zipCode",
editText.getText().toString() );

                 Intent i = new Intent(getApplicationContext(),
LocationSearchResults.class);
                 i.putExtras(bundle);
                 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);


                View view =
BranchSearchHelper.branchSearch.getLocalActivityManager().startActivity("Locations
Results",i).getDecorView();

                 BranchSearchHelper.branchSearch.replaceView(view);
           }
}
View view =
BranchSearchHelper.branchSearch.getLocalActivityManager().startActivity("Locations
Results",i).getDecorView();