我有两项活动(Activity A, Activity B
) In Activity A
我有一个EditText,Button and Image View
And in 活动B我有一个Listview和 listView 视图包含 CustomXml 与ImageView,TextView,and Another TextView
在活动 A 中,我在编辑文本中输入列表名称(Ex : Apple)
我在 GridView 中选择一张图像(Ex an Apple Image )
我将 Edittext 和 ImageView 都传递给一个新的 Activity,我想在 ListView 中显示这些名称(Apple 和 Apple Image)
我想显示这样的东西(我从上一个活动中获取杂货列表和图像,并且我想在ListView中显示(在listview中我额外添加了项目计数TEXTVIEW)
第一个Activity.Java
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String itemname = listname.getText().toString();
if (!TextUtils.isEmpty(listname.getText().toString())) {
startActivity(new Intent(getContext(), CheckslateHome.class).putExtra("data", itemname).putExtra("image", imageRes));
dismiss();
} else {
Toast.makeText(getContext(), "List Name not Empty ", Toast.LENGTH_SHORT).show();
}
}
});
第二项活动
公共类 CheckslateHome 扩展 AppCompatActivity {
TextView listcounts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_checkslate_home);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
String itemName= bundle.getString("data");
Int ItemImage = bundle.getString("Image");
**//How to Pass these Intents into the Custom ListView**
}
listcounts = findViewById(R.id.list_count);
ListView listView = findViewById(R.id.list1);
CustomAdpter customAdapter = new CustomAdpter();
listView.setAdapter(customAdapter);
}
public class CustomAdpter extends BaseAdapter {
private Context context;
private LayoutInflater layoutInflater;
@Override
public int getCount() {
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = layoutInflater.inflate(R.layout.rowlayout, viewGroup, false);
}
ImageView imageicons = view.findViewById(R.id.image_list);
TextView listnames = view.findViewById(R.id.list_name);
return view;
}
}