使用捆绑和意图与TabHost [英] Using Bundle and Intent with TabHost

查看:61
本文介绍了使用捆绑和意图与TabHost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用TabHost与3个标签。我需要通过使用捆绑和/或意向到下一个屏幕中选择的PARAMS,然后设置在TabHost正确的选项卡,并通过这些PARAMS正确的选项卡。我希望是有道理的。我有了被分组几个单选按钮和1复选框和一个按钮一个配置屏幕。在我的onClick()我有以下code。

I am using TabHost with 3 tabs. I need to pass the params selected from one screen using Bundle and / or Intent to the next and then set the correct tab in TabHost and pass those params to the correct tab. I hope that makes sense. I have a config screen that has several radio buttons that are grouped and 1 checkbox and a button. in my onClick() I have the following code.

public class Distribute  extends Activity implements OnClickListener {
DistributionMap gixnav;
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TextView textview = new TextView(this);
    textview.setText("Distribution");
    setContentView(R.drawable.configup);

    Button button = (Button)findViewById(R.id.btn_configup1);
    button.setOnClickListener(this);        
}

public void onClick(View v) {
    Intent intent;
    Bundle extras = new Bundle();

    intent = new Intent().setClass(getApplicationContext(), Clevel.class);
    intent.putExtras(extras);
    startActivity(intent);

}    

}

我需要通过选择PARAMS(其中单选按钮被选中,是复选框,单击以Clevel在Clevel我要解析的包和这些PARAMS运行。Basiclaly我将拉动数据弗罗马DB并使用该数据调用谷歌地图ItemizedOverlay。

I need to pass the selection params (which radio button is selected and is the checkbox clicked to Clevel. In Clevel I have to parse the bundle and operate on those params. Basiclaly I will be pulling data froma DB and using that data to call google maps ItemizedOverlay.

使用的onClick调用意向Clevel.class。这工作,我了解意向的作品。我需要了解的是如何抓住或引用选定的单选按钮和其他任何可能被点击或检查,并通过TabHost传递到正确的选项卡。这是我在为Clevel TabHost。从TabHost的onclick需要的一切传递给Distribute.class

onClick calls Clevel.class using Intent. This works and I understand how Intent works. What I need to understand is how to grab or reference the selected radio button and whatever else may be clicked or checked and pass it through TabHost to the correct Tab. This is what I have in Clevel for TabHost. From TabHost the onCLick will need to pass everything to Distribute.class

public class Clevel extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gixout1);
    Resources res = getResources(); 
    TabHost tabHost = getTabHost();  
    TabHost.TabSpec spec; 
    Intent intent;  


    String mData;

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mData = extras.getString("key");

    }

    intent = new Intent().setClass(this, ClevelMain.class);
    spec = tabHost.newTabSpec("Main").setIndicator("C-Level",
                      res.getDrawable(R.drawable.gixmain))
                  .setContent(intent);
    tabHost.addTab(spec);
    intent = new Intent().setClass(this, Distribute.class);
    spec = tabHost.newTabSpec("Config").setIndicator("Distribute",
                      res.getDrawable(R.drawable.gixconfig))
                  .setContent(intent);
    tabHost.addTab(spec);
    intent = new Intent().setClass(this, DistributionMap.class);
    spec = tabHost.newTabSpec("Nav").setIndicator("Map",
                      res.getDrawable(R.drawable.gixnav))
                  .setContent(intent);
    tabHost.addTab(spec);
    tabHost.setCurrentTab(3);
    tabHost.getOnFocusChangeListener();

}

我期待就如何通过在捆绑使用PARAMS和是否应该使用捆绑一些指针和意图,或者我可以只使用意向?

I am really looking for some pointers on how to pass and use params in Bundle and whether in should use Bundle and Intent or can I just use Intent?

在此先感谢,
帕特

Thanks in advance, Pat

推荐答案

这将是对您有用。

共享选项卡之间的数据...

这篇关于使用捆绑和意图与TabHost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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