I am a student and new to programming. It might be a simple error, can anybody help me fix it.I have to pass an array list from one activity to another. In this activity i have 5 radio buttons RB1, RB2.... and i want to pass the content of news[] it to another activity called display.
public void onClick(View v) {
String[] news;
news = new String[5];
news[0] = "bbc";
news[1] = "guardian";
news[2] = "yahoo";
news[3] = "sky";
news[4] = "fox news";
final ArrayList<String> arr = new ArrayList<String>();
if (RB1.isChecked() == true)
arr.add(news[0]);
if (RB2.isChecked() == true)
arr.add(news[1]);
if (RB3.isChecked() == true)
arr.add(news[2]);
if (RB4.isChecked() == true)
arr.add(news[3]);
if (RB5.isChecked() == true)
arr.add(news[4]);
if (v == Done)
{
Button done = (Button) findViewById(R.id.DONE);
done.setOnClickListener(new View.OnClickListener() {
public void onClick(View view)
{
Intent myIntent = new Intent(Read.this, display.class);
myIntent.putExtra("pass",arr);
startActivity(myIntent);
}
});
}
the codes for next activity is as follows
Intent myintent = getIntent();
String[] Array = myintent.getStringArrayExtra("pass");
for (int i = 0; i < Array.length; i++)
Log.v(LOG_TAG, "THE website Is :" +Array[i]);
I am geting a java.lang.NullPointerException in the above two line i.e
for (int i = 0; i < Array.length; i++)
Log.v(LOG_TAG, "THE website Is :" +Array[i]);
can u pls tell me why ? thanks in advance