Reputation: 59
I want to use an value array from one class to another class. In ActivityReceiver, I took an array and pass it into String inkLevel [][].
After that I want to get the specific value,so that I have getInkLevel and return it into array that save the specific value(which is color[]) that I want.
public class ActivityReceiver extends Activity {
public ArrayList<String[]> arrays ;
public String[]color = new String [4];
public String[][] inkLev ;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
if (bundle != null)
{
int count = bundle.getInt("com.PrinterStatus.AppLab.ARRAYS_COUNT", 0);
ArrayList<String[]> arrays = new ArrayList<String[]>(count);
for (int i = 0; i < count; i++)
{
arrays.add(bundle.getStringArray("com.PrinterStatus.AppLab.ARRAY_INDEX" + i));
String[][] inkLev = arrays.toArray(new String[][]{});
}
}
}
public String[] getInkLevel(String[] lev)
{
color[0]= inkLev[0][2];
color[1]= inkLev[1][2];
color[2]= inkLev[2][2];
color[3]= inkLev[3][2];
return color;
}
In another class. I have enterednumberC variable. And I want to put the specific value,example color[1] into that variable.
...
tonerAmountC = (TextView)mSmartView.findViewById(R.id.ImageC);
tonerAmountC.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
enterednumberC = ??;
Log.d(SampleExtensionService.LOG_TAG, "Read from file: " + enterednumberC);
tonerAmountC.setText(enterednumberC);
}
});
mSmartView.addViewToWatch(tonerAmountC);
...
Do you know what should I add?Thank You
Upvotes: 0
Views: 84
Reputation: 13576
YOu need to retrieve the array first using. You need an instance of the class to access the array
someStringArray = new ActivityReceiver().getInkLever();
enteredNumberC = someStringArray[1];
Upvotes: 1