【发布时间】:2018-02-05 08:01:54
【问题描述】:
是否可以将Intent 值从一个Activity 放入另一个ListView 中的Activity?
以下是来自Activity1 的值,我想将它们放入Activity2 中的ListView:
try
{
jsonobject = new JSONObject(json);
jsonarray = jsonobject.getJSONArray("user");
JSONObject jb= jsonarray.getJSONObject(0);
//Username = jb.getString("Username");
Password = jb.getString("Password");
Fullname = jb.getString("Fullname");
Email = jb.getString("Email");
Bio = jb.getString("Bio");
Location = jb.getString("Location");
fn.setText(Fullname);
em.setText(Email);
loc.setText(Location);
b.setText(Bio);
if(json!=null)
{
Intent i = new
Intent(HomePageActivity.this,ProfileActivity.class);
i.putExtra(u.username(), u.getUsername());
i.putExtra("password",Password);
i.putExtra("fullname",Fullname);
i.putExtra("email", Email);
i.putExtra("bio", Bio);
i.putExtra("location", Location);
startActivity(i);
finish();
}
}catch(Exception e)
{
e.printStackTrace();
}
【问题讨论】:
-
将您的值添加到
ArrayList<String>,使用Intent传递给另一个活动,将字符串列表检索到另一个活动中并将值绑定到ListView -
即使按照您的方式进行操作也可以。您面临的问题是什么?
-
我终于将arraylist的值显示到listview了!!谢谢各位
标签: java android listview android-activity