How can I print out the information I entered in the list view?

Asked 2 years ago, Updated 2 years ago, 24 views

JSONObject mDataJO = new JSONObject();

String adress = etmapname.getText().toString();
String adress_descript = etadress.getText().toString();
String roomInfo = etroomInfo.getText().toString();
String described = etdescribed.getText().toString();
int deposit = Integer.parseInt(etPrice.getText().toString());
int monthly_rent = Integer.parseInt(etmonthly_rent.getText().toString());
int acreage = Integer.parseInt(etacreage.getText().toString());

try {
      mDataJO.put("adress",adress);
      mDataJO.put("adress_descript",adress_descript);
      mDataJO.put("deposit",deposit);
      mDataJO.put("roomInfo",roomInfo);
      mDataJO.put("described",described);
      mDataJO.put("monthly_rent",monthly_rent);
      mDataJO.put("acreage",acreage);
      mDataJO.put("img",img);
      Log.e("dh","server req:\n"+mDataJO.toString());
} } catch (JSONException e) {
    e.printStackTrace();
}

Hello, I'm a student who just learned Android. I'm asking you a question because I can't get the hang of it. If you enter the information into Jason like this and press the OK button, In the list view of other activities, I'd like to add a brief picture and content.

How do I write and input the code? Please.

android

2022-09-22 20:13

1 Answers

Implementing the desired functionality requires some prior learning. Please check the contents below.

Adding items dynamically to the list view

Forwarding data between activities

If you want to transfer the JSONObject of the code you uploaded to another activity, it is one of the ways to simply apply the following code.

intent.putString("data", mDataJO.toString());

In incoming activities

JSONObject mDataJO = new JSONObject(getIntent().getStringExtra("data")); 


2022-09-22 20:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.