Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rcc2.www.listview;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.ListView;
- import java.util.ArrayList;
- public class ListViewActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_listview);
- ArrayList<Mobile> arrayList = new ArrayList<>();
- Mobile m1 = new Mobile();
- m1.setName("Nokia");
- m1.setPrice(6400);
- m1.setImage(R.drawable.ic_launcher_background);
- arrayList.add(m1);
- Mobile m2 = new Mobile();
- m2.setName("Huawei");
- m2.setPrice(5700);
- m2.setImage(R.drawable.ic_launcher_background);
- arrayList.add(m2);
- Mobile m3 = new Mobile();
- m3.setName("Sony");
- m3.setPrice(8400);
- m3.setImage(R.drawable.ic_launcher_background);
- arrayList.add(m3);
- Mobile m4 = new Mobile();
- m4.setName("LG");
- m4.setPrice(4200);
- m4.setImage(R.drawable.ic_launcher_background);
- arrayList.add(m4);
- ListView listView = findViewById(R.id.listView);
- MobileAdapter mobileAdapter = new MobileAdapter(ListViewActivity.this, R.layout.row_design, arrayList);
- listView.setAdapter(mobileAdapter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement