第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用Intent.putExtra發(fā)送數(shù)組

使用Intent.putExtra發(fā)送數(shù)組

開滿天機(jī) 2019-08-08 15:10:08
使用Intent.putExtra發(fā)送數(shù)組我在活動(dòng)A中有一個(gè)整數(shù)數(shù)組:int array[] = {1,2,3};我想將該變量發(fā)送到活動(dòng)B,因此我創(chuàng)建了一個(gè)新的intent并使用了putExtra方法:Intent i = new Intent(A.this, B.class);i.putExtra("numbers", array);startActivity(i);在活動(dòng)BI中獲取信息:Bundle extras = getIntent().getExtras();int arrayB = extras.getInt("numbers");但這并不是真的發(fā)送數(shù)組,我只是在arrayB上得到值'0'。我一直在尋找一些例子,但我沒有發(fā)現(xiàn)任何事情。
查看完整描述

3 回答

?
慕森卡

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊

您正在使用數(shù)組設(shè)置額外的。然后你試圖得到一個(gè)int。

你的代碼應(yīng)該是:

int[] arrayB = extras.getIntArray("numbers");


查看完整回答
反對(duì) 回復(fù) 2019-08-08
?
慕容3067478

TA貢獻(xiàn)1773條經(jīng)驗(yàn) 獲得超3個(gè)贊

此代碼發(fā)送整數(shù)值數(shù)組

初始化數(shù)組列表

List<Integer> test = new ArrayList<Integer>();

將值添加到數(shù)組列表

test.add(1);test.add(2);test.add(3);Intent intent=new Intent(this, targetActivty.class);

將數(shù)組列表值發(fā)送到目標(biāo)活動(dòng)

intent.putIntegerArrayListExtra("test", (ArrayList<Integer>) test);startActivity(intent);

在這里你可以獲得targetActivty的值

Intent intent=getIntent();ArrayList<String> test = intent.getStringArrayListExtra("test");


查看完整回答
反對(duì) 回復(fù) 2019-08-08
?
GCT1015

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超4個(gè)贊

final static String EXTRA_MESSAGE = "edit.list.message";Context context;public void onClick (View view){   
    Intent intent = new Intent(this,display.class);
    RelativeLayout relativeLayout = (RelativeLayout) view.getParent();

    TextView textView = (TextView) relativeLayout.findViewById(R.id.textView1);
    String message = textView.getText().toString();

    intent.putExtra(EXTRA_MESSAGE,message);
    startActivity(intent);}


查看完整回答
反對(duì) 回復(fù) 2019-08-08
  • 3 回答
  • 0 關(guān)注
  • 1112 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)