목록의 항목보기 View.if 첫 번째 항목을 클릭합니다. 내가 activit을 시작하고 일부 이미지를 표시합니다. 두 번째 목록 항목을 클릭하면 다른 활동이 시작되고 일부 활동이 시작됩니다. 이미지 집합입니다. 여기에 목록보기 코드가 있습니다. package com.example.per.app;이미지 어댑터가 포함 된 ListView
public class AlbumListActivity extends Activity {
public String[] mListInfo = { "1st Month", "2nd Month", "3rd Month",
"4th Month", "5th Month", "6th Month", "7th Month", "8th Month",
"9th Month", "10th Month", "11th Month", "12th Month" };
public ListView mList = null;
public Intent mLaunch = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.list_album);
mList = (ListView) findViewById(R.id.list_view);
ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(
getApplicationContext(), android.R.layout.simple_list_item_1,
mListInfo);
mList.setAdapter(mAdapter);
mList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
switch (arg2) {
case 0:
mLaunch = new Intent(getApplicationContext(),FirstMonthActivity.class);
startActivity(mLaunch);
}
}
});
}
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView imageView;
if (arg1 == null) { // if it's not recycled, initialize some
// attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(363, 363));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(0, 0, 0, 0);
} else {
imageView = (ImageView) arg1;
}
imageView.setImageResource(mThumbIds[arg0]);
return imageView;
} // references to our images
Integer[] mThumbIds = { R.drawable.sample0, R.drawable.sample1,
R.drawable.sample2, R.drawable.sample3, R.drawable.sample4,
R.drawable.sample5, R.drawable.sample6, R.drawable.sample7,
R.drawable.sample8, R.drawable.sample9 };
}
}
보기 항목의 이미지 항목 클래스를 유지해야합니까? 목록 항목마다 다른 이미지 집합을 표시하고 싶습니다.
현재 케이스 0 만 추가하고 케이스 1 케이스 2 케이스 3 ... 케이스 12를 추가 할 예정입니다. 따라서 12 개의 activities.in 각 액티비티를 시작해야합니다. 다른 이미지 세트를 표시하고 싶습니다.
저는 List에 12 개의 항목이 있습니다. res 폴더에 120 개의 이미지가 있습니다. 각 List 항목에 대해 10 개의 이미지를 표시하고 싶습니다. 어떻게해야합니까? – chait
수정 된 답변보기 및 궁금한 점이 있으면 알려주십시오. – ayon
그래서 내 코드에서 ImageAdaper 클래스를 사용하여 이미지를로드했습니다. 클래스가 필요하지 않으므로 위의 코드를 참조하십시오. – chait