안드로이드 개발 질문/답변
(글 수 45,052)
자바파일ㄹ
public class ProfessorClass extends Activity{
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); //정보안나옴!
setContentView(R.layout.professorclass);
GridView gridview = (GridView) findViewById(R.id.professorclass);
gridview.setAdapter(new ImageAdapter(this));
gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
// Toast.makeText(getApplicationContext(),"이그림을 선택하셨습니다." + position, Toast.LENGTH_SHORT).show();
}
});
}
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 position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(150, 150));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(5, 5, 5, 5);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.kunsan, R.drawable.notice,
R.drawable.notice, R.drawable.notice,
R.drawable.notice, R.drawable.notice,
R.drawable.notice, R.drawable.notice,
R.drawable.notice, R.drawable.notice,
R.drawable.notice, R.drawable.notice,
R.drawable.notice
};
}
}
레이아웃부분!
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff" >
<GridView
android:id="@+id/professorclass"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
</LinearLayout>
지금 이러면 사진들이 그리드뷰에 나타나는데요! 이걸 사진을 클릭시 사진이뜨고 아래로는 스크롤나오고 텍스트설명이 나오게 하고 싶습니다. 그리고 다른사진을 클릭하면 사진도 바뀌고 텍스트설명도 바뀌게 하고 싶습니다. 어떻게 해야하는지 알려주세요!



