I am new to android.
In my Activity class i get a link value by hitting an URL as below code.
try {
JSONArray jsonarray = new JSONArray(response);
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobject = jsonarray.getJSONObject(i);
String name = jsonobject.getString("Sno");
String Tktid = jsonobject.getString("TKTID");
link = jsonobject.getString("Link");
List list = new List(jsonobject.getString("Sno"), jsonobject.getString("TKTID"),jsonobject.getString("Link"));
tktList.add(list);
Log.i("website content", name);
Log.i("website content", Tktid);
Log.i("website content", link);
}
//creating custom adapter object
ListViewAdapter adapter = new ListViewAdapter(tktList, getApplicationContext());
//adding the adapter to listview
listView.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
//displaying the error in toast if occurrs
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
And i am Assigning that value to a button in a Adapter class like below.
TextView textViewName = listViewItem.findViewById(R.id.textViewName);
TextView textViewImageUrl = listViewItem.findViewById(R.id.textViewImageUrl);
Button btupdate = listViewItem.findViewById(R.id.btupdate);
List hero = tktList.get(position);
btupdate.setText(hero.getLink());
btupdate.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(mCtx, Main3Activity.class);
i.putExtra("Link",view.getId());
mCtx.startActivity(i);
}
});
Now here what my requirement is to Access that assigned link value in an other activity to retrieve some data related to that value.
Please hep me any one.
Use this:
btupdate.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(mCtx, Main3Activity.class);
i.putExtra("Link",btupdate.getText().toString().trim());
(or)
i.putExtra("Link",hero.getLink());
mCtx.startActivity(i);
}
});
Inside Main3Activity.java
Oncreate(){
Bundle bundle = getIntent().getExtras();
String message = bundle.getString("Link");
}
}
you just replace this below code
TextView textViewName = listViewItem.findViewById(R.id.textViewName);
TextView textViewImageUrl = listViewItem.findViewById(R.id.textViewImageUrl);
Button btupdate = listViewItem.findViewById(R.id.btupdate);
List hero = tktList.get(position);
btupdate.setText(hero.getLink());
btupdate.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent i = new Intent(mCtx, Main3Activity.class);
i.putExtra("Link",hero.getLink());
mCtx.startActivity(i);
}
});
Related
how do I setText value when I on click button?
now, I can get the value from my DB, but how can set text when I click the button?
private JsonArrayRequest getDataFromServer(int requestCount) {
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Load...");
final String DATA_URL = "https://aaa.ccc/eee.php";
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(DATA_URL,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
parseData(response);
progressDialog.dismiss();
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
}
});
return jsonArrayRequest;
}
private void loadTravelRule() {
requestQueue.add(getDataFromServer(requestCount));
requestCount++;
}
private void parseData(JSONArray array) {
for (int i = 0; i < array.length(); i++) {
TravelRuleModel travelRuleModel = new TravelRuleModel();
JSONObject json = null;
try {
json = array.getJSONObject(i);
String TAG_TravelRule = "TravelRule";
travelRuleModel.setTravelrule(json.getString(TAG_TravelRule));
} catch (JSONException e) {
e.printStackTrace();
}
travelRuleModels.add(travelRuleModel);
}
}
I can get json.getString(TAG_TravelRule) value, but I want to set value in here.
tips.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this, R.style.BottomSheetDialogTheme);
View bottomSheetView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.tips, (LinearLayout)findViewById(R.id.bottomSheetContainer));
travel_rule = findViewById(R.id.travel_rule);
// Can I set value to R.id.travel_rule in R.layout.tips???
if it is can set value how can I do?
bottomSheetDialog.setContentView(bottomSheetView);
bottomSheetDialog.show();
}
});
I tried to used
rule = json.getString(TAG_TravelRule);
then
travel_rule.setText(rule);
but I got null
I suppose the textview is on the bottomSheetView xml so you have to reference that to find your textview
travel_rule = bottomSheetView.findViewById(R.id.travel_rule);
I am currently using recycler view to load courses using JSON, the first course has its id in JSON that is one, and then the second, each course has its id that is stored in the db. I want that if I click the first button it should save its ID that is one to my session manager and pass it to the next activity to load its corresponding data, and when I click on the 2nd button it should load data by passing its respective ID. I have attached the onclick of my recycler view, it should get the ID of the button clicked and store it into a string that I will then store into the session manager.
private RecyclerView mRecyclerView;
private CourseAdapter mExampleAdapter;
private ArrayList<CourseItem> mExampleList;
private RequestQueue mRequestQueue;
private static final String URL_PRODUCTS = "https://www.sniptx.com/ws/findTeacher/allCourses.php";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
mRecyclerView = (RecyclerView) findViewById(R.id.course_recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(this, mRecyclerView, new RecyclerItemClickListener
.OnItemClickListener() {
#Override
public void onItemClick(View view, int position) {
Toast.makeText(HomeActivity.this, "Item Clicked" + position , Toast.LENGTH_LONG).show();
}
#Override
public void onItemLongClick(View view, int position) {
//handle longClick if any
}
}));
mExampleList = new ArrayList<>();
mRequestQueue = Volley.newRequestQueue(this);
parseJSON();
}
private void parseJSON() {
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_PRODUCTS,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONObject obj = new JSONObject(response);
JSONArray courseArray = obj.getJSONArray("courses");
for (int i = 0; i < courseArray.length(); i++) {
JSONObject courseObject = courseArray.getJSONObject(i);
String courseName = courseObject.getString("c_name");
String id = courseObject.getString("c_id").trim();
l.add(new CourseItem(courseName, id));
}
try {
JSONArray array = new JSONArray(response);
for (int i = 0; i < array.length(); i++) {
JSONObject product = array.getJSONObject(i);
String courseName = product.getString("c_name");
String id = product.getString("id").trim();
mExampleList.add(new CourseItem(courseName, id));
Toast.makeText(HomeActivity.this,"ID is" +id, Toast.LENGTH_SHORT).show();
}
mExampleAdapter = new CourseAdapter(HomeActivity.this, mExampleList);
mRecyclerView.setAdapter(mExampleAdapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
});
Volley.newRequestQueue(this).add(stringRequest); }
}
Use Intent to set the data(i.e id of clicked button)as extra params of intent in first activity and get the intent extras in second activity.
// first activity
Intent i = new Intent(getApplicationContext(), SecondActivity.class);
i.putExtra("id", value);
startActivity(i);
// second activity
Bundle extras = getIntent().getExtras();
int id = extras.getInt("id");
I am looking for some help with a tutorial I have been working on. I am trying to pass an object when I click on a list item from one activity to another using an Intent. I have posted some of the tutorial code I have been using below but can't seem to get it to work.
My Main Activity code is below:
StringRequest stringRequest = new StringRequest(Request.Method.GET, GET_HEROES_URL,
new Response.Listener<String>() {
#Override
public void onResponse(String response) {
try {
JSONArray array = new JSONArray(response);
for(int i =0; i<array.length(); i++){
JSONObject obj = array.getJSONObject(i);
Hero hero = obj.getString("name"));
heroList.add(hero);
}
adapter = new HeroAdapter(heroList, getApplicationContext());
recyclerView.setAdapter(adapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
And from my Adapter this is the code I have been using this:
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
final Hero hero = heroList.get(position);
holder.textViewName.setText(hero.getName());
holder.textViewName.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(context, HeroDetailActivity.class);
intent.putExtra(KEY_HERO_ID, hero.getName());
context.startActivity(intent);
}
});
}
The intent is listed but it is not carrying the data into my new activity. I just want to take
hero.getName()
at the position it was clicked on in the itemlist and open up a new activity, and in the new activity set it to a TextView. This is part of code I have used on the new activity, but it wont post anything into the TextView.
TextView textViewName
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hero_detail);
textViewname = (textView) findViewById(R.id.textView);
Intent intent = getIntent();
if(intent == null)
return;
int id = intent.getIntExtra(HeroAdapter.KEY_HERO_ID, -1);
err.setText(id);
For instance I click on spiderman set in the list which is at position 3, and in the new activity the textView will load with Spiderman listed. Any help would be appreciated.
You can pass objects using serializable or parcelable interfaces but if you just want the name of your hero you should pass it as string in your intent. Now you're passing an id. You can totally do that. If it's int you should set it correctly to textview
err.setText(String.valueOf(id));
That's why it's not working now.
Or just pass it as string right from the beginning
Intent intent = new Intent(context, HeroDetailActivity.class);
intent.putExtra(KEY_HERO_NAME, hero.getName());
context.startActivity(intent);
And then retrieve it
Intent intent = getIntent();
if(intent == null)
return;
String heroName = intent.getStingExtra(HeroAdapter.KEY_HERO_NAME);
err.setText(heroName);
Try with this:
int id = -1;
if(getIntent().hasExtra(HeroAdapter.KEY_HERO_ID)){
id = getIntent().getExtras().getInt(HeroAdapter.KEY_HERO_ID);
}
err.setText("" + id);
If you need send the hero name then:
In your adapter:
Intent intent = new Intent(context, HeroDetailActivity.class);
intent.putExtra(KEY_HERO_ID, hero.getName());
context.startActivity(intent);
In your activity:
String heroName = "";
if(getIntent().hasExtra(HeroAdapter.KEY_HERO_ID)){
heroName = getIntent().getExtras().getString(HeroAdapter.KEY_HERO_ID);
}
err.setText(heroName);
i am trying to populate a spinner from a URl but i cant get the elements on to spinner using the GET method...my POST method works well to do the registration...But cant GET data to spinner...this is my code
public class SuppRegActivity extends AppCompatActivity implements RegistrationView,View.OnClickListener {
EditText company_name,code,Add1,Add2,Add3,Add4,Tel_no,mob_no,email,contact_person,tin_no,password;
Spinner state;
Button save;
ArrayList<String> mystates;
ArrayList<JSONObject> err;
String Get_company_name,Get_code,Get_Add1,Get_Add2,Get_Add3,Get_Add4,Get_Telno,
Get_mobno,Get_email,Get_contactp,Get_tinno,Get_password,Get_state;
RegistrationPresenter registrationPresenter;
ProgressDialog progressDialog;
View v;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_supp_reg);
company_name = (EditText) findViewById(R.id.suppname);
code = (EditText) findViewById(R.id.suppcode);
Add1 = (EditText) findViewById(R.id.Add1);
Add2 = (EditText) findViewById(R.id.Add2);
Add3 = (EditText) findViewById(R.id.Add3);
Add4 = (EditText) findViewById(R.id.Add4);
Tel_no = (EditText) findViewById(R.id.suppPhone);
mob_no = (EditText) findViewById(R.id.SuppMob);
email = (EditText) findViewById(R.id.suppEmail);
contact_person= (EditText) findViewById(R.id.SuppPerson);
tin_no = (EditText) findViewById(R.id.SuppTin);
password = (EditText) findViewById(R.id.suppPass);
state = (Spinner) findViewById(R.id.suppstate);
save = (Button) findViewById(R.id.Saveregister);
save.setOnClickListener(this);
//arr = new ArrayList<JSONObject>();
registrationPresenter = new RegistrationPresenterImpl(this, SuppRegActivity.this);
}
#Override
public void onClick(View view) {
Get_company_name = company_name.getText().toString();
Get_Add1 = Add1.getText().toString();
Get_Add2 = Add2.getText().toString();
Get_Add3 = Add3.getText().toString();
Get_Add4 = Add4.getText().toString();
Get_state = state.getSelectedItem().toString();
Get_Telno = Tel_no.getText().toString();
Get_mobno = mob_no.getText().toString();
Get_email = email.getText().toString();
Get_contactp = contact_person.getText().toString();
Get_tinno = tin_no.getText().toString();
Get_code = code.getText().toString();
Get_password = password.getText().toString();
if(!Get_company_name.equals("")){
if(!Get_Add1.equals("")){
if(!Get_Add2.equals("")){
if(!Get_Add3.equals("")){
if(!Get_Add4.equals("")){
if(!Get_state.equals("")){
if(!Get_Telno.equals("")){
if(Get_Telno.length() ==10 ){
if(!Get_mobno.equals("")){
if(Get_mobno.length() == 10){
String emailPattern = "[a-zA-Z0-9._-]+#[a-z]+\\.+[a-z]+";
if(Get_email.matches(emailPattern)){
if(!Get_contactp.equals("")){
if(!Get_tinno.equals("")){
if(!Get_code.equals("")){
if(!password.equals("")){
doRegisteration(Get_company_name,Get_code,Get_Add1,Get_Add2,Get_Add3,Get_Add4,Get_state,Get_Telno,Get_mobno,Get_email,Get_contactp,
Get_tinno,Get_password);
}else{
showFailedAlertBox("Password in Required");
}
}else{
showFailedAlertBox("user name is required");
}
}else{
showFailedAlertBox("enter Tin No.");
}
}else{
showFailedAlertBox("enter contact person");
}
}else{
showFailedAlertBox("invalid email");
}
}else{
showFailedAlertBox("enter 10 digit phone no");
}
}else{
showFailedAlertBox("enter mobile no");
}
}else{
showFailedAlertBox("enter 10 digit phone no.");
}
}else{
showFailedAlertBox("enter mobile no");
}
}else{
showFailedAlertBox("State not selected");
}
}else{
showFailedAlertBox("Address line 4 required");
}
}else{
showFailedAlertBox("Address line 3 required");
}
}else{
showFailedAlertBox("Address line 2 required");
}
}else{
showFailedAlertBox("Address line 1 required");
}
}else{
showFailedAlertBox("Company name is required");
}
}
private void showSuccessAlertBox(final String v) {
new AlertDialog.Builder(this).setMessage(v)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
if (v.equals("Registration Done")) {
/* // String uNameForIntent = company_name.getText().toString().trim();
Intent intent = new Intent(SuppRegActivity.this, MainActivity.class);
// intent.putExtra("uname", uNameForIntent);
startActivity(intent);*/
}
else{
return;
}
}
}).show();
}
#TargetApi(Build.VERSION_CODES.KITKAT)
public void doRegisteration(String companyname, String code, String Add1, String Add2, String Add3, String Add4, String State, String tel_no,
String mobileno, String email, String contactp, String tinno, String password){
/*JSONObject stat = new JSONObject();
try{
JSONObject a = stat.getJSONObject("getAllState");
for(int i=0;i<a.length();i++) {
JSONObject c=(JSONObject) a.get(i);
}
} catch (JSONException e) {
e.printStackTrace();
}*/
JSONObject register= new JSONObject();
try {
register.put("FullName",Get_company_name);
register.put("Alias",Get_code);
register.put("Add1", Get_Add1);
register.put("Add2", Get_Add2);
register.put("Add3", Get_Add3);
register.put("Add4", Get_Add4);
register.put("State",Get_state);
register.put("TelNo",Get_Telno);
register.put("mobile", Get_mobno);
register.put("email", Get_email);
register.put("TinNo",Get_tinno);
register.put("ContactPerson", Get_contactp);
register.put("Password", Get_password);
JSONObject s = register.getJSONObject("http://.............................../getAllState");
err = new ArrayList<JSONObject>();
err.add(s);
ArrayAdapter<JSONObject> adapter = new ArrayAdapter<JSONObject>(this,android.R.layout.simple_spinner_item,err);
state.setAdapter(adapter);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String REGISTER_URL =" http://........................../AddAccount";
//String STATE_URL = "http://.........................../getAllState";
showProgress();
/*JsonObjectRequest statelist = new JsonObjectRequest(Request.Method.GET, STATE_URL, stat,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
state.setAdapter(new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_item,arr));
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
}
});*/
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, REGISTER_URL,register,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
JSONObject j = null;
String result = null;
try {
result = response.getString("Result");
} catch (JSONException e) {
e.printStackTrace();
}
if (result.equals("Saved")) {
showSuccessAlertBox("Registration Done");
//volleyForProfile(sessionManager.getUserName());
}
else
showFailedAlertBox("Failed Process!!!Try Again");
hidePregress();
}
},
new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
hidePregress();
}
}
);
request.setRetryPolicy(new DefaultRetryPolicy(
30000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
VolleyApplication.getInstance().getRequestQueue().add(request);
}
private void showFailedAlertBox(String v) {
new AlertDialog.Builder(this).setMessage(v)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}).show();
}
#Override
public void showProgress() {
progressDialog = ProgressDialog.show(SuppRegActivity.this, "Please Wait",
"Processing...", true);
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
}
#Override
public void hidePregress() {
progressDialog.dismiss();
}
#Override
public void setErrorOnEditText() {
/*Snackbar.make(v, msg, Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
showSuccessAlertBox(msg);*/
}
#Override
public void savedMsg(String msg) {
}
}
where REGISTER_URL uses the post method....and STATE_URL uses the GET Method...
First instead of accepting response as JSON object use instance of a custom POJO class of your own depending on your requirements. And secondly you can create a custom adapter class for populating your spinner.
If you have a small requirement like mentioned above I'd suggest you should use Retrofit instead of Volley which is lightweight and fast.
I have a code here and i want to pass the hash map function by clicking save button. I looked Here but cannot find the solution for me.
oN Click the button i need to pass the hasmap.Anyone please help for this.My Codes is:
btnsave = (Button) findViewById(R.id.btn_save);
btnsave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
expandableDataPump.getData();
Intent intent = new Intent(getApplicationContext(), ExpandableList.class);
//HERE I NEED TO PASS HASHMAP
intent.putStringArrayListExtra("details",(HashMap<String,>) expandableDataPump.getData());
startActivity(intent);
} catch (Exception ex) {
ex.printStackTrace();
Toast.makeText(MainActivity.this, "You have an ERROR", Toast.LENGTH_LONG).show();
}
}
});
}
public class ExpandableDataPump {
public HashMap<String, List<String>> getData() {
HashMap<String, List<String>> expandableListDetail = new HashMap<>();
for (int i = 2; i < container.getChildCount(); i++) {
if (container.getChildAt(i) instanceof RelativeLayout) {
List<String> childs = new ArrayList<>();
childs.add(((TextView)container.getChildAt(i).findViewById(R.id.textout)).getText().toString());
expandableListDetail.put(txtHeading.getText().toString(), childs);
}
}
return expandableListDetail;
}
}
}
You are doing it wrong, all Collections are serializable, in order to pass hashmap into intent you use
putExtra(String key, Serializable obj)
and to get the array back from intent, you do
getIntent().getSerializableExtra(String key)
Your Answer
btnsave = (Button) findViewById(R.id.btn_save);
btnsave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
Intent intent = new Intent( getApplicationContext(), S.class );
intent.putExtra( "details", getData() );
startActivity(intent);
} catch (Exception ex) {
ex.printStackTrace();
Toast.makeText(MainActivity.this, "You have an ERROR", Toast.LENGTH_LONG).show();
}
}
});
public HashMap< String, List< String > > getData() {
HashMap< String, List< String > > expandableListDetail = new HashMap<>();
for ( int i = 2 ; i < container.getChildCount() ; i++ ) {
if ( container.getChildAt( i ) instanceof RelativeLayout ) {
List< String > childs = new ArrayList<>();
childs.add( ( ( TextView ) container.getChildAt( i ).findViewById( R.id.textout ) ).getText().toString() );
expandableListDetail.put( txtHeading.getText().toString(), childs );
}
}
return expandableListDetail;
}
You can do this by just following below instruction.
First Create class with implements Serializable as shown below.
public class DataWrapper implements Serializable{
private HashMap<String,List<String>> hasmap;
public DataWrapper(HashMap<String,List<String>> hasmap){
this.hasmap= hasmap;
}
public HashMap<String,List<String>> getHashMap(){
return this.hasmap;
}
}
In activity from where you want to pass HashMap<String,List<String>> put below code.
DataWrapper dw = new DataWrapper(expandableDataPump.getData());
Intent intent = new Intent(getApplicationContext(), ExpandableList.class);
intent.putExtra("details", dw);
startActivity(intent);
In your ExpandableList activity retrieve DataWrapper object and the retrieve your HashMap from that object as shown below.
try{
Intent intent = getIntent();
DataWrapper dw = (DataWrapper) intent.getSerializableExtra("details");
HashMap<String,List<String>> hasmap = dw.getHashMap();
} catch(Exception e){
}
that's it. Its working for me.
Use
extras.putSerializable("HashMap",Hash_Map);
intent.putExtras(extras);
Instead of
intent.putStringArrayListExtra("details",(HashMap) expandableDataPump.getData());
btnsave = (Button) findViewById(R.id.btn_save);
btnsave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
expandableDataPump.getData();
Intent intent = new Intent(getApplicationContext(), ExpandableList.class);
intent.putExtra("details",(HashMap<String,>) expandableDataPump.getData());
startActivity(intent);
} catch (Exception ex) {
ex.printStackTrace();
Toast.makeText(MainActivity.this, "You have an ERROR", Toast.LENGTH_LONG).show();
}
}
});
}
To pass the HashMap,
btnsave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
Intent intent = new Intent(getApplicationContext(), ExpandableList.class);
intent.putExtra("details", expandableDataPump.getData());
startActivity(intent);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
To retrieve it in ExpandableList,
HashMap<String,List<String>> hashmap = (HashMap<String,List<String>>) getIntent().getSerializableExtra("details");