안녕하세요?^^ JAVA언어를 배우면서 안드로이드에 관심이 생기고,
현재 안드로이드에 관한 조그마한 프로젝트를 진행하고 있는 한 학생? 입니다.
다름이아니라 gallery와 gridview를 구현은 했으나, 이미지를 클릭하고 확대를 하고 싶은데요..
책도 읽어봤고 구글링도 해봤지만 제가 딱 적용할만한 예제나 소스가 없어서 이렇게 글을 올리게 됐네요..
이미지를 클릭했을때 에뮬레이터의 전체창으로 확대를 하고 싶은데 소스나 간단한 예제를 알려주시면 정말 감사하겠습니다.
p.s 이미지는 현재까지 구현한 이미지입니다.^^
package com.oreilly.hellogallery; import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class helloGallery extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Gallery g = (Gallery) findViewById(R.id.gallery); g.setAdapter(new ImageAdapter(this)); g.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { Toast.makeText(helloGallery.this, "" + position, Toast.LENGTH_SHORT).show(); } }); } public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private Integer[] mImageIds = { R.drawable.f1, R.drawable.f2, R.drawable.f3, R.drawable.f4, R.drawable.f5, R.drawable.f6 }; public ImageAdapter(Context c) { mContext = c; TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); mGalleryItemBackground = a.getResourceId( R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle(); } public int getCount() { return mImageIds.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]); i.setLayoutParams(new Gallery.LayoutParams(150, 100)); i.setScaleType(ImageView.ScaleType.FIT_XY); i.setBackgroundResource(mGalleryItemBackground); return i; } } } ====================== 여기서 부턴 main. xml입니다. ========================== <?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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Gallery xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
String [] proj={MediaStore.Images.Media.DATA};
cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,proj, null,null, null);
column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToPosition(position);
String filename = cursor.getString(column_index);
Toast.makeText(GalleryExample.this, filename, Toast.LENGTH_SHORT).show();
맞는지는 잘 모르겠는데요...이걸 Listener 에 추가하신 후에 토스트에서 filename 확인 하신 후에 잘 나오면 인텐트로 값 넘겨줘서
거기에서 출력시키면 될 것 같네요....확신은 못하겠습니다 ㅠㅠ
죄송합니다만 에뮬레이터 스킨 어떠게 한건가요.. 이뻐요..