当我使用ArrayList自定义适配器在列表视图中列出图像时,代码没有显示任何错误。问题是,在使用代码时,只有我最后输入的数据在列表视图中显示。为什么不能查看之前输入的数据?
我的活动课:
public class SocialActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_social);
String json;
ImageView babu = (ImageView) findViewById(R.id.babu);
ListView lvsoc = (ListView) findViewById(R.id.list_social);
LinearLayout l1 = (LinearLayout) findViewById(R.id.layhead);
LayoutInflater inflater = null;
ArrayList<SubjectData> arrayList = new ArrayList<SubjectData>();
ArrayAdapter<SubjectData> a;
/*ArrayList<String> allcategory = new ArrayList<>();
ArrayList<String> allcategory1 = new ArrayList<>();
ArrayList<String> img = new ArrayList<>();
ArrayList<String> img1 = new ArrayList<>();*/
arrayList.add(new SubjectData("JAVA", "https://www.tutorialspoint.com/java/", "https://s18955.pcdn.co/wp-content/uploads/2017/11/Facebook-share-icon.png"));
arrayList.add(new SubjectData("Python", "https://www.tutorialspoint.com/python/", "https://www.tutorialspoint.com/python/images/python-mini.jpg"));
/*arrayList.add(new SubjectData("Javascript", "https://www.tutorialspoint.com/javascript/", "https://www.tutorialspoint.com/javascript/images/javascript-mini-logo.jpg"));
arrayList.add(new SubjectData("Cprogramming", "https://www.tutorialspoint.com/cprogramming/", "https://www.tutorialspoint.com/cprogramming/images/c-mini-logo.jpg"));
arrayList.add(new SubjectData("Cplusplus", "https://www.tutorialspoint.com/cplusplus/", "https://www.tutorialspoint.com/cplusplus/images/cpp-mini-logo.jpg"));
DIEA
相关分类