我正在从Localhost服务器上的MySQL数据库获取数据,并在ListView
中显示一些数据(用户名,电子邮件)不完整。我想打开新活动中单击的ListView
项目的完整详细信息(用户名,电子邮件,父亲名称,资格,联系方式等)。
活动1代码
lvViewAllData.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent( getApplicationContext(), SingleUser.class );
tvGetUsername = (TextView)findViewById( R.id.tvUsernameDisplayRow);
String username = tvGetUsername.getText().toString();
intent.putExtra("username", username );
startActivity( intent );
}
}
);
我要在其中显示完整数据的活动2代码
public class SingleUser extends AppCompatActivity {
String GET_USERNAME;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_user_layout);
GET_USERNAME = getIntent().getExtras().getString("username");
TextView textView = (TextView)findViewById(R.id.tvUsernameSigleUser);
textView.setText(GET_USERNAME);
}
}
答案 0 :(得分:0)
lvViewAllData.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
CompleteData completeData = customAdopter.getItem(position);
Intent intent = new Intent( getApplicationContext(), SingleUser.class );
String username = completeData.getUsername();
intent.putExtra("username", username );
startActivity( intent );
}
}
);