English 中文(简体)
4. 安妮·布纳特概念在活动间传递
原标题:Android Bundle Concept to pass deta between activities
  • 时间:2011-10-12 19:12:05
  •  标签:
  • android

我来到这里是新鲜事,在试图通过从治疗器到捆绑的检索数据时,我面临着问题,当时我无法得到这一变量的价值。 下面是我的法典,请帮助我摆脱这种状况。

Cursor cur3 = db3.rawery(“SlectT” * 摘自“+ TableName, 无);

try {

            db3  = this.openOrCreateDatabase("remoteid.db", MODE_PRIVATE, null);

            if(cur3 != null )  
            {   
                if(cur3.moveToFirst())
                {
                    do {
                        valueOfID =  cur3.getString(cur3.getColumnIndex("PretestID"));
                         valuOfDate = cur3.getString(cur3.getColumnIndex("Date"));
                         textType = cur3.getString(cur3.getColumnIndex("txtVCT"));                                                      
                         valueOfDDLTS = cur3.getString(cur3.getColumnIndex("ddlTestingSession"));
                         valueOfReason = cur3.getString(cur3.getColumnIndex("txtReason"));
                         valueOfHowmany = cur3.getString(cur3.getColumnIndex("txthowmany"));
                         valueOftxtques1 = cur3.getString(cur3.getColumnIndex("txtques1"));
                         valueOfrblques2a = cur3.getString(cur3.getColumnIndex("rblques2a"));
                         valueOfrblques2b = cur3.getString(cur3.getColumnIndex("rblques2b"));
                         valueOfrblques3 = cur3.getString(cur3.getColumnIndex("rblques3"));
                         valueOftxtques4 = cur3.getString(cur3.getColumnIndex("txtques4"));
                         valueOfrblques5 = cur3.getString(cur3.getColumnIndex("rblques5"));
                         valueOfrblques6 = cur3.getString(cur3.getColumnIndex("rblques6"));
                         valueOfrblques7 = cur3.getString(cur3.getColumnIndex("rblques7"));
                         valueOfrblques8 = cur3.getString(cur3.getColumnIndex("rblques8"));
                         valueOfrblques9 = cur3.getString(cur3.getColumnIndex("rblques9"));
                         valueOfddlsick = cur3.getString(cur3.getColumnIndex("ddlsick"));
                         valueOftxtques11 = cur3.getString(cur3.getColumnIndex("txtques11"));
                         valueOfrblques12 = cur3.getString(cur3.getColumnIndex("rblques12"));
                         valueOftxtques13 = cur3.getString(cur3.getColumnIndex("txtques13"));
                         valueOftxtques14 = cur3.getString(cur3.getColumnIndex("txtques14"));
                         valueOfrblques15 = cur3.getString(cur3.getColumnIndex("rblques15"));
                         valueOfrblques16 = cur3.getString(cur3.getColumnIndex("rblques16"));
                         valueOfrblques17 = cur3.getString(cur3.getColumnIndex("rblques17"));
                         valueOftxtques18 = cur3.getString(cur3.getColumnIndex("txtques18"));

                         //Toast.makeText(getApplicationContext(), valueOftxtques18, Toast.LENGTH_SHORT).show();

                    }while (cur3.moveToNext());
                }
            }

        }

        catch(Exception e) {
            Log.e("Error", "Error", e);

        } finally {
            if (db3 != null)
                db3.close();
        }
        cur3.close();   



        arrayadapter11 = new simpleefficientadapter(Screening.this,prtestData);
        arrayadapter22 = new simpleefficientadapter(Screening.this,screeningData);
        arrayadapter33 = new simpleefficientadapter(Screening.this,postData);

        mylist1.setAdapter(arrayadapter11);
        mylist1.setOnItemClickListener(this);
        mylist2.setAdapter(arrayadapter22);
        mylist2.setOnItemClickListener(this);
        mylist3.setAdapter(arrayadapter33);
        mylist3.setOnItemClickListener(this);
    }


    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        Intent intent;
        switch (arg0.getId()) {
        case R.id.prescreenlist:            
            intent = new Intent(getApplicationContext(), NewScreening.class);       
            Bundle bundle = new Bundle();   

            bundle.putString("DateValue", valuOfDate);  
            bundle.putString("TT", textType);   
            bundle.putString("idValue", valueOfID); 
            bundle.putString("ddltsValue", valueOfDDLTS);   
            bundle.putString("reasonValue", valueOfReason); 
            bundle.putString("howmanyValue", valueOfHowmany);   
            bundle.putString("textqus1Value", valueOftxtques1); 
            bundle.putString("textqus2aValue", valueOfrblques2a);   
            bundle.putString("textqus2bValue", valueOfrblques2b);   
            bundle.putString("rbqs3Value", valueOfrblques3);    
            bundle.putString("rbqs4Value", valueOftxtques4);    
            bundle.putString("rbqs5Value", valueOfrblques5);    
            bundle.putString("rbqs6Value", valueOfrblques6);    
            bundle.putString("rbqs7Value", valueOfrblques7);    
            bundle.putString("rbqs8Value", valueOfrblques8);    
            bundle.putString("rbqs9Value", valueOfrblques9);    
            bundle.putString("ddlsValue", valueOfddlsick);  
            bundle.putString("tq11Value", valueOftxtques11);    
            bundle.putString("tq12Value", valueOfrblques12);    
            bundle.putString("tq13Value", valueOftxtques13);    
            bundle.putString("tq14Value", valueOftxtques14);    
            bundle.putString("rbqs15Value", valueOfrblques15);  
            bundle.putString("rbqs16Value", valueOfrblques16);
            bundle.putString("rbqs17Value", valueOfrblques17);  
            bundle.putString("rbqs18Value", valueOftxtques18);

            intent.putExtras(bundle);

            startActivityForResult(intent, 1);

            setResult(1,intent);


            break;
最佳回答

A wiser move, might be passing the id of that database row to the next Activity.

And your code is incomplete, but it looks like only the last row s data will ever be passed to the next activity.

而且,如果你只是将外溢直接带入意图,而不是中间的布纳特,那么这或许会提高效率和明确性。

良好做法据说将包裹的名称列为外名的预设物。

问题回答

暂无回答




相关问题
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 ...

热门标签