リストビューのチェックボックスの値を次のアクティビティに渡したいです。次のアクティビティは、チェックボックスの値を取得するAndroid json解析アクティビティになります。問題は、チェックボックスの値を渡す方法ですか?
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.SparseBooleanArray;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Button;
import android.widget.AdapterView.OnItemClickListener;
public class Item extends Activity implements OnClickListener{
String [] builder;
Button button;
ListView listView;
String [] array = new String[] {"Baby Cot ", "Bouncer", "Bottle", "Blanket", "Stroller", "Toy", "Walker", "Thermal Bag", "Storage Bag", "Diaper", "Pacifier", "Potty", "Baby Bath" , "Baby CD", "Baby Book", "Car Seat", "Teethers", "Cooler Bag", "High Chair", "Apparel"};
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, array);
listView = (ListView) findViewById(R.id.list);
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
button = (Button) findViewById (R.id.testbutton);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
SparseBooleanArray positions = listView.getCheckedItemPositions();
for (int index = 0; index <array.length; index++){
if (positions.get (index) == true)
{
builder[index] = array[index];
}
}
Intent i = new Intent(this, AndroidJSONParsingActivity.class);
Bundle b = new Bundle();
b.putStringArray("list", builder);
i.putExtras(b);
startActivity(i);
}
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3){
}
}