Я всегда получаю исключение nullPointerException при запуске действия karsilastir в моем коде здесь, отправляя код активности:
karsilastir.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent_notify=new Intent();
intent_notify.setClass(Evraka1Activity.this,karsilastir.class);
Bundle bundle=new Bundle();
bundle.putStringArrayList("urunler", urunler);
intent_notify.putExtra("urunler",bundle);
//startService(intent_notify);
startActivity(intent_notify);
}
здесь получите код активности:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.karsilastirmasonuclari);
Intent intent = getIntent();
Bundle b = intent.getExtras();
gelenurunler = b.getStringArrayList("urunler");
}
Это зависит от типа arraylist (копируется отсюда)
Затем вы можете прочитать от вас следующее действие, заменив put на get с ключевой строкой в качестве аргумента, например
myIntent.getStringArrayListExtra("arrayPeople");
Обновлено ::
Intent i = new Intent(this,name.class);
Bundle b = new Bundle();
b.putIntegerArrayListExtra(String name, ArrayList<Integer> value);
i.putExtra(String name,b);
startActivity(i);
И получить данные в другую деятельность, такую как
Bundle b = getIntent().getExtra().putParcelableArrayListExtra(String name);
Создайте локальную переменную поля члена в верхней части вашего класса. M обозначает поле члена и является частью стандартов стиля кодирования Android. Ознакомьтесь с учебным пособием по Android Notepad для справки.
http://developer.android.com/resources/tutorials/notepad/notepad-ex2.html
public class karsilastir extends ListActivity {
/* Create an instance variable just below the class constructor. */
ArrayList mUrunler;
....
karsilastir.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent_notify=new Intent();
intent_notify.setClass(Evraka1Activity.this,karsilastir.class);
Bundle bundle=new Bundle();
bundle.putStringArrayList("urunler", mUrunler);
intent_notify.putExtra("urunler",bundle);
//startService(intent_notify);
startActivity(intent_notify);
}
}