Я новичок в программировании для Android и не могу правильно использовать синтаксис glide (т.е. с (context) и загружать протоколы) в пользовательском адаптере. Пожалуйста, дайте мне знать, что я делаю неправильно. Заранее спасибо
Пробовал изменить контекст на view1 и создать новый контекст
String[] HelmetNames = {"Helmet 1","Helmet 2","Helmet 3","Helmet 4","Helmet 5","Helmet 6"};
int[] HelmetImages = {R.drawable.a7021906,R.drawable.a7021038,R.drawable.a2111976,R.drawable.a7751025,R.drawable.a3739,R.drawable.a2661082};
String[] HelmetDetails={"4-point ratchet suspension allows wearer to customize height and fit\n • Suspension sits lower on head to reduce pressure and increase security\n • Short brim enhances better upward visibility\n • Slots allow for attachment of safety accessories\n\n\n\nhttps://multimedia.3m.com/mws/media/828564O/3m-head-protection-hard-hats-101-technical-bulletin.pdf","4-point ratchet suspension allows wearer to customize height and fit\n • Suspension sits lower on head to reduce pressure and increase security\n • Short brim enhances better upward visibility\n • Slots allow for attachment of safety accessories\n\n\n\nhttps://multimedia.3m.com/mws/media/828564O/3m-head-protection-hard-hats-101-technical-bulletin.pdf","4-point ratchet suspension allows wearer to customize height and fit\n • Suspension sits lower on head to reduce pressure and increase security\n • Short brim enhances better upward visibility\n • Slots allow for attachment of safety accessories\n\n\n\nhttps://multimedia.3m.com/mws/media/828564O/3m-head-protection-hard-hats-101-technical-bulletin.pdf","4-point ratchet suspension allows wearer to customize height and fit\n • Suspension sits lower on head to reduce pressure and increase security\n • Short brim enhances better upward visibility\n • Slots allow for attachment of safety accessories\n\n\n\nhttps://multimedia.3m.com/mws/media/828564O/3m-head-protection-hard-hats-101-technical-bulletin.pdf","4-point ratchet suspension allows wearer to customize height and fit\n • Suspension sits lower on head to reduce pressure and increase security\n • Short brim enhances better upward visibility\n • Slots allow for attachment of safety accessories\n\n\n\nhttps://multimedia.3m.com/mws/media/828564O/3m-head-protection-hard-hats-101-technical-bulletin.pdf","4-point ratchet suspension allows wearer to customize height and fit\n • Suspension sits lower on head to reduce pressure and increase security\n • Short brim enhances better upward visibility\n • Slots allow for attachment of safety accessories\n\n\n\nhttps://multimedia.3m.com/mws/media/828564O/3m-head-protection-hard-hats-101-technical-bulletin.pdf"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_headgrid);
//finding listview
gridView = findViewById(R.id.gridview);
CustomAdapter customAdapter = new CustomAdapter();
gridView.setAdapter(customAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Toast.makeText(getApplicationContext(),HelmetNames[i],Toast.LENGTH_LONG).show();
Intent intent = new Intent(getApplicationContext(),HeadGridItemActivity.class);
intent.putExtra("name1",HelmetNames[i]);
intent.putExtra("image1",HelmetImages[i]);
intent.putExtra("details1",HelmetDetails[i]);
startActivity(intent);
}
});
}
private class CustomAdapter extends BaseAdapter {
@Override
public int getCount() {
return HelmetImages.length;
}
@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) {
View view1 = getLayoutInflater().inflate(R.layout.row_datahead,null);
//getting view in row_data
TextView name = view1.findViewById(R.id.helmetname);
ImageView image = view1.findViewById(R.id.helmetimages);
Glide.with(context)
.load(HelmetImages[i])
.into(image);
name.setText(HelmetNames[i]);
// image.setImageResource(HelmetImages[i]);
return view1;
}
}
}