0

Hi I am trying to pass my ArrayList value into my TabLayout but I am getting null value please help me...I successfully passed my string value but ArrayList value only null...

here I am trying to pass my string and ArrayList value..........

this is my code:

sdcardImages.setOnItemClickListener(new OnItemClickListener() {


            public void onItemClick(AdapterView parent, View v, int position, long id) {
                Intent intent = new Intent(ParxmlActivity.this, tabview.class);
                intent.putExtra("spec",model_List.get(position).spec);
                intent.putExtra("mimage",model_List.get(position).mimage);
                intent.putStringArrayListExtra("imageList", model_List.get(position).imageList);

                startActivity(intent);  

            }
        });

the 1st and 2nd value working fine....spec and mimage but imageList only i am getting null value......

public class tabview extends TabActivity {
    Bundle tab_intent;
    public static String spec, mimage, imageList;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.viewtab);
        tab_intent=tabview.this.getIntent().getExtras();
        spec=tab_intent.getString("spec");
        mimage = tab_intent.getString("mimage");
        imageList =  tab_intent.getString("imageList");

above code I am try to get my values the ImageList value only shows null what is the reason?

code:

package ml.ml;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;

public class schild {
    public String name;
    public String model;
    public String spec;
    public String mimage;
    //public String imageList;
    //public String videoList;
    public ArrayList<String> imageList;
    public ArrayList<String> videoList;


    public schild(){
        name = new String();
        model = new String();
        spec = new String();
        mimage = new String();
        imageList = new ArrayList<String>();
        videoList = new ArrayList<String>();
        //imageList =new String();
        //videoList = new String();

    }


}

here I am adding to separate ArrayList

for(int j = 0; j<model_List.size(); j++){

                mname_List.add(model_List.get(j).name);
                mmimage.add(model_List.get(j).mimage);
                mspec_List.add(model_List.get(j).spec);
                mvideo_List.addAll(model_List.get(j).videoList);
                mmimage_List.addAll(model_List.get(j).imageList);
            }

this is value I am trying to passing in tab host.......

2
  • stackoverflow.com/questions/3939331/… Commented Feb 9, 2012 at 12:16
  • 3
    interesting ... in first Activity you're putting StringArrayList and in second you're expecting to get a String ... seems like you do not understand your own code ... Commented Feb 9, 2012 at 12:19

1 Answer 1

0

Change your tabview class:

ArrayList<String> imageList;
...

@Override
public void onCreate(Bundle savedInstanceState) {
    ...
    imageList =  tab_intent.getStringArrayList("imageList");
    ...
}

Upd: You're trying to take String from Bundle where is ArrayList<String> located.

Sign up to request clarification or add additional context in comments.

8 Comments

error: Type mismatch: cannot convert from ArrayList<String> to String
change declaration of imageList
ok i changed ArrayList<String> imageList; now also i am getting error:The method getStringArrayList(String) in the type Bundle is not applicable for the arguments (ArrayList<String>)
What and where did you changed? You shouldn't get this error.
Ask new question about spinner.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.