package com.LijslGallery;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
public class LijslGalleryActivity extends Activity {
String[] str;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dest);
GridView g = (GridView) findViewById(R.id.dhaval);
g.setAdapter(new ImageAdapter(this));
}
public class ImageAdapter extends BaseAdapter {
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
// string array
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if (convertView == null) {
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icon, null);
ImageView iv = (ImageView) v.findViewById(R.id.icon_image);
iv.setImageResource(mThumbIds[position]);
} else {
v = convertView;
}
return v;
}
@SuppressWarnings("unused")
private Context mContext;
private Integer[] mThumbIds = {
R.drawable.calendar, R.drawable.clubs, R.drawable.fandd,
R.drawable.gallery, R.drawable.links, R.drawable.mylijsl,
R.drawable.latesth, R.drawable.sponsors, R.drawable.register,
R.drawable.news, R.drawable.tryouts,R.drawable.programs
};
}
}
///////////////////////////////icon.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget44" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:orientation="vertical"
android:gravity="center_horizontal">
<ImageView android:id="@+id/icon_image" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
</LinearLayout>
No comments:
Post a Comment