android怎麼用intent傳遞二維陣列

時間 2022-04-10 05:40:59

1樓:匿名使用者

1.宣告乙個二維陣列.

2.寫乙個for迴圈,將一維陣列放到intent的bundle裡.

起始就是往bundle裡存放了多個一維陣列而已.

final string data = new string ;

bundle bundle = new bundle();

for (int i = 0; i < data.lenth; i++)

bundle.putstringarray(array_index + i, data[i]);

2樓:匿名使用者

public class twobean implements serializable

存資料string ss=new string[2][2];

ss[0][0]="1";

ss[0][1]="2";

ss[1][0]="3";

ss[1][1]="4";

twobean bean=new twobean();

bean.ss=ss;

intent mintent=new intent();

mintent.putextra("data", bean);

拿資料twobean bean=(twobean) getintent().getextras().get("data");

string bb=bean.ss;

android activity間傳二維陣列問題

3樓:匿名使用者

1樓說的很對,在另乙個activity接收,我再補充一下,

string strarray = getintent().getserializableextra("intarray")

也可以用這種方式傳遞物件、map集合等,傳遞物件的實體類要實現系列化。接受就用上面的方法,傳過來的是什麼物件,就強轉一下就好了。

4樓:匿名使用者

bundle map = new bundle();

map.putserializable("intarray", new int);

map.putserializable("strarray",new string);

intent.putextra("data", map);

android 中如何使用intent通過傳遞變數傳遞資料

5樓:

intent intent =new intent(aactivity.this,bactivity.class);

intent.putextra("num1", num1) ;

intent.putextra("num2", num2) ;

startactivity(intent) ;

另乙個接受的是activity是 :

string num1 =this.getintent().getstringextra("num1") ;

string num2 =this.getintent().getstringextra("num2") ;

基本就這樣

6樓:匿名使用者

private static final string database_name = "test.db";

private static final int database_version = 1;

public class databasehelper extends sqliteopenhelper

這樣就可以了,引數先定義好就可以了啊。你可以再試試。我也是做android開發的,有問題可以和我交流,我的qq是379371398,希望採納。

android開發intent怎麼傳遞集合

android程式設計中用intent傳值能傳乙個變數到另乙個activity嗎?

7樓:匿名使用者

intent intent= new intent(當前activity.this, 要跳轉到的activity.class);

bundle bundle=new bundle();

bundle.putint("a", "值");//這你看你要傳什麼值,int--putint("key","值");

intent.putextras(bundle);//把這個值放到intent裡面

startactivity(intent);//跳轉

------------------------------------------

這裡已經跳轉到另乙個activity了

在oncreat裡寫這樣的**

intent intent=new intent();

bundle b=new bundle();

//比如這個是string或者int型的:

string str=b.getstring("key");

int a=b.getint("key");

----------------------------------------

這樣就完全ok了,好好加油吧,這條路還很長呢

8樓:匿名使用者

intent it = new intent(activity.main.this, activity2.class);

bundle bundle=new bundle();

bundle.putint("a", "值");

it.putextras(bundle);

startactivity(it);

新activity中oncreate方法中取傳遞過來的值bundle bundle = this.getintent().getextras();

int a = bundle.getint("a");

android怎麼顯示用intent傳遞過去的字串? 20

9樓:匿名使用者

跟layout沒關係,第乙個activity用intent傳了以後,在接收這個的activity中寫:

intent intent=getintent();

string result=intent.getstringextra("extra_data");

這樣就獲得那個值了,列印一般用log日誌,比如log.i("sec","result-- "+result);

或者彈出toast.maketext(context, "result---"+result, toast.length_short).show();

android怎麼用intent傳遞arraylist<類>

10樓:匿名使用者

你說的普通的類是什麼?有沒有包含二進位制資料(比如**之類的)?

如果僅僅是類似實體類那樣,沒有二進位制資料的,有2種方法實現serializable或者parcelable介面(google建議使用parcelable)

將物件轉為gson字串傳遞

11樓:匿名使用者

你說的是傳遞物件吧。可以先序列化再反序列化。

12樓:子丶夜

bundle args = new bundle();

arraylist parce_list = new arraylist();

parce_list.add(model);

args.putparcelablearraylist("list_source", parce_list);

android intent傳遞引數問題

13樓:

//bundle bundle = new bundle(); //這句是多餘的

bundle bundle = this.getintent().getextras();

categoryselected = bundle.getstring("category");

pcode = bundle.getstring("pcode");

上面說的問題與你提的問題關係不大,感覺你的問題不太可能啊,請檢查傳入的時候:

bundle.putstring("category", category);

請檢查傳入的時候category本來就是空指標。

14樓:匿名使用者

一定是你的**的問題,傳漢字是正常的!

檢查下你的key對不對!或者**對不對,在傳入引數bundle bundle=new bundle();

bundle.putstring("category", category);

bundle.putstring("pcode", citypcode);

intent.putextras(bundle);

最後一行新增斷點除錯下,到底傳之前是啥值

15樓:匿名使用者

intent 傳值,學習中

android,怎麼把乙個activity的context資料通過intent傳到新的activity。

怎麼用eclipse編寫android

青鳥中關村專家 目前android開發工具主要有兩種 eclipse和android studio。其中android studio可以直接進行android開發,但是eclipse則需要新增adt外掛程式才可以進行android開發,下面就解說一下如何使得eclipse實現android開發。工具...

android程式設計用怎麼讓控制項的「右邊」對齊在螢幕的中心

跟你說說xml裡面的布局吧。首先可以在linearlayout裡面將其設定為horizontal 水平 然後再在裡面寫button,button的width每個都為 px。然後你調第二個button的layout marginleft的值為 6px 反正這個值你自己適當調就行。用relativela...

我用eclipse編寫的android程式無法執行

eclipse編寫的android程式無法執行可能的原因如下 eclipse本身沒有安裝好,沒有載入好對應的android的jar包。android程式本身存在bug,如果沒有修復的話,是無法執行的。adb程序被系統殺死,需要重啟才能使用。這個問題我也遇到過,原理是跟 ghc創業者 差不多。我寫了乙...

android自定義控制項怎麼用,如何自定義iOS中的控制項

ios中得控制項,大家並不陌生。那麼如何來自定義乙個控制項呢,對於純粹的顯示類的控制項我們在這裡不再贅述,只是說一下自定義控制項,如何響應點選訊息。一 uicontrol中的觸控事件響應函式 自定義乙個控制項,如果是需要響應點選訊息 拖動訊息,大多是直接繼承自uicontrol,在不熟悉下面所要講的...

Android開發中怎樣用多程序,用多程序的好

1.怎樣用多程序。android多程序概念 一般情況下,乙個應用程式就是乙個程序,這個程序名稱就是應用程式包名。我們知道程序是系統分配資源和排程的基本單位,所以每個程序都有自己獨立的。資源和記憶體空間,別的程序是不能任意訪問其他程序的記憶體和資源的。如何讓自己的應用擁有多個程序 四大元件在andro...