English 中文(简体)
列表布局2项活动之间的转让数据
原标题:transfer data between 2 activities in a tab layout

I am implementing a fitness app. I have a tab layout for this app, the first tab shows the location(latitude, longitude), speed and other status, and the second tab shows a google map where the running route will be shown as a polyline in the map.

第一个表格活动有一个接收新地点的地点经理。

我的问题是:我如何把第一件表所列活动中从地点主管收到的数据转移到“gogle”地图表格活动?

如我所知,通过使用意图,输出和启动()可在两个活动之间转让数据,但要求启动()活动。 我将立即着手进行地图活动? 但我想更新地图中的多线,保持原状状态。

任何方面?

提前感谢:

问题回答

Create One Global class and declare static varible and assign value to it and use another class. And another way

Intent i =new Intent()setClass(this, ListViewerIncompleted.class);
i.putStringArrayListExtra(name, value);

Ok i通过该法典解决这一问题:

在我的Login活动(1st activity)中,需要通过用户名和密码说明:

btnLogin.setOnClickListener(new OnClickListener(){
        public void onClick(View v) {               
            String userName = txtUsername.getText().toString();
            String password = txtPass.getText().toString();
            //instance for UserFunctions.
            UserFunctions userFunction = new UserFunctions();
            JSONObject json = userFunction.loginUser(userName, password);
            //Check login response
            try {
                if(json.getString(KEY_REQUESTRESULT)!= null ){
                    txtErrorM.setText("");
                    //Log.e("Passed fine:", "first if condition");
                    String res = json.getString(KEY_REQUESTRESULT);//Obtaining the value 0 or 1 from the KEY loginstatus from JSONObject.
                if(Integer.parseInt(res) == 1){
                    Intent iii = new Intent("com.mariposatraining.courses.MariposaTrainingActivity");
                    Bundle bundle1 = new Bundle();
                    Bundle bundle2 = new Bundle();
                    bundle1.putString("UN", userName);
                    bundle2.putString("PW", password);
                    iii.putExtras(bundle1);
                    iii.putExtras(bundle2);

                    //iii.putExtra("userName", userName);
                    //iii.putExtra("Password", password);                       
                    startActivity(iii);
                    finish();
                    //Log.e("OBJECTOO", json.toString());
                }

i 将这些指令发送至图瓦卢武装部队,然后转交管理这一信息的活动:

public class MariposaTrainingActivity extends TabActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    WindowManager.LayoutParams.FLAG_FULLSCREEN); 
    setContentView(R.layout.main);

    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec ; //recurse to the property tabs
    Intent intent; //intent for open tabs

    //created intent for open the class tab1

    intent = new Intent().setClass(this, ListViewerIncompleted.class); //List 2 Incompleted
    spec = tabHost.newTabSpec("ListViewerIncompleted").setIndicator("INCOMPLETED").setContent(intent);
    tabHost.addTab(spec);
    Bundle bundle1 = getIntent().getExtras();
    String userName=bundle1.getString("UN");
    Bundle bundle2 = getIntent().getExtras();
    String password=bundle2.getString("PW");
    Bundle bundle3 = new Bundle();
    Bundle bundle4 = new Bundle();
    bundle3.putString("UN", userName);
    bundle4.putString("PW", password);
    intent.putExtras(bundle3);
    intent.putExtras(bundle4);}}

在班级使用这一信息:

 Bundle bundle3 = getIntent().getExtras();
    String userName=bundle3.getString("UN");   //Getting the userName
    Bundle bundle4 = getIntent().getExtras();
    String password=bundle4.getString("PW");

希望能给你们带来想法......

在您的目的地使用公共静态变量,以便立即从源活动中获得所需的价值。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签