开发者

Retrieving passed String Array elements - Android

I believe I am passing a String array from Class A to Class B correctly, however I am having a bit of trouble accessing each element individually. Here is a general view of my code.

String[] inputArr = new String[4];
//CLASS A=====================================          
inputArr[0] = zero;
inputArr[1] = one;
inputArr[2] = two;
inputArr[3] = three;

Bundle bundle = new Bundle();
bundle.putStringArray("input",inputArr);

//CLASSB==================================================
Bundle bundle = this.getIntent().getExtras();
String[] myStrings = new String[4];
myStrings = bundle.getStringArray("input");

So if this is correctly getting passed, then how would I go about assigning indivdual strings in Class B to the elements in th开发者_如何学编程e passed array? I have tried:

String aStr = myStrings[0];

However, this is showing the error message - "syntax error on token ";", Expression expected after this token." Is this the wrong method to use in this situation? If so, what should I be using? Thank you for your help in advance.


Incase of Class A

i.putExtra("input",inputArr); 

In case of Class B

Bundle extras = getIntent().getExtras();
int arrayB = extras.getStringArray("numbers"); 


Try

String[] myStrings = getIntent().getStringArray("input");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜