我想在 android studio 中制作一个仪表板。我使用两个 xml 来制作仪表板 main_activity 和 list_item 活动。在编码会话中,我使用了模型类适配器和主类。
public class MainActivity extends AppCompatActivity {
ArrayList<DashModel> dashModelArrayList;
DashAdapter dashAdapter;
private RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.rv1);
dashModelArrayList = new ArrayList<>();
String heads[] = {"Jobs", "My Profile", "Messages", "Applied Jobs", "Resume", "Settings"};
String subs[] = {"12 new jobs found", "75% complete", "2 new messages", "3 applies jobs", "Edit resume", "Set preferences"};
int images[] = {R.drawable.find_jobs, R.drawable.profile, R.drawable.messages, R.drawable.applied_jobs,
R.drawable.resume, R.drawable.settings};
for (int count = 0; count < heads.length; count++) {
DashModel dashModel = new DashModel();
dashModel.setHead(heads[count]);
dashModel.setSub(subs[count]);
dashModel.setImage(images[count]);
dashModelArrayList.add(dashModel);
//this should be retrieved in our adapter
}
recyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 2));
dashAdapter = new DashAdapter(dashModelArrayList);
recyclerView.setHasFixedSize(true);
recyclerView.setAdapter(dashAdapter);
}}
如何在此处添加 onItemclickListener?
我希望并希望在图标中添加 OnItemclickListener,但我不能也不知道如何添加。
心有法竹
相关分类