Могу ли я сохранить значения строк из списка MulitiColumnView в Simple ListView в следующей операции?

Как получить значение из пользовательского ListView с двумя столбцами в Simple ListView в следующем Activity.i есть select1 и select2 String [] variables.Myval – глобальная переменная.i имеют следующие Исключения *

Исключения в logcat:

07-31 10:37:55.470: E/AndroidRuntime(974): FATAL EXCEPTION: main 07-31 10:37:55.470: E/AndroidRuntime(974): java.lang.NullPointerException 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.AbsListView.obtainView(AbsListView.java:2033) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.ListView.makeAndAddView(ListView.java:1772) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.ListView.fillDown(ListView.java:672) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.ListView.fillFromTop(ListView.java:732) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.ListView.layoutChildren(ListView.java:1625) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.AbsListView.onLayout(AbsListView.java:1863) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.View.layout(View.java:11278) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewGroup.layout(ViewGroup.java:4224) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.View.layout(View.java:11278) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewGroup.layout(ViewGroup.java:4224) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.FrameLayout.onLayout(FrameLayout.java:431) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.View.layout(View.java:11278) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewGroup.layout(ViewGroup.java:4224) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.View.layout(View.java:11278) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewGroup.layout(ViewGroup.java:4224) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.widget.FrameLayout.onLayout(FrameLayout.java:431) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.View.layout(View.java:11278) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewGroup.layout(ViewGroup.java:4224) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.os.Handler.dispatchMessage(Handler.java:99) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.os.Looper.loop(Looper.java:137) 07-31 10:37:55.470: E/AndroidRuntime(974): at android.app.ActivityThread.main(ActivityThread.java:4424) 07-31 10:37:55.470: E/AndroidRuntime(974): at java.lang.reflect.Method.invokeNative(Native Method) 07-31 10:37:55.470: E/AndroidRuntime(974): at java.lang.reflect.Method.invoke(Method.java:511) 07-31 10:37:55.470: E/AndroidRuntime(974): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 07-31 10:37:55.470: E/AndroidRuntime(974): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 07-31 10:37:55.470: E/AndroidRuntime(974): at dalvik.system.NativeStart.main(Native Method) 

Получить значение от Spinner:

  public void onItemSelected(AdapterView<?> parent, View arg1, int pos,long id) { String Text = parent.getSelectedItem().toString(); if(Text.equals("----SELECT----")) { } else if(Text.equals("BEVERAGES")){ select1=new String[Beverage.length]; select2=new String[P1.length]; System.out.println("Length of Beverage:" + select1.length); System.out.println("Length of P1:" + select2.length); select1 = Beverage; select2 = P1; l1.setAdapter(new EfficientAdapter(HomeActivity.this)); return; } 

Получить значение из Custom ListView:

  l1.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(HomeActivity.this, "SELECTED :: " + "item "+select1[position] + " " + "price"+ select2[position], Toast.LENGTH_SHORT).show(); String ss=(String)parent.getItemAtPosition(position); GlobalClass.myval.add(ss); 

Замените следующие вещи в своем коде, он может предоставить вам некоторые
L1.setAdapter (новый EfficientAdapter (HomeActivity.this)); Замените на: l1.setAdapter (новый EfficientAdapter (HomeActivity.this), arraytosendtoadapter); // сменим ваш эффективный адаптер на наличие String [], чтобы получить то, что вы отправляете

Intereting Posts