So I have Added a button. My Whole code looks like: ************************************************************************************************ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.Gallery; import android.widget.ImageView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener;
public class DisplayViewsExample extends Activity { //---the images to display--- Integer[] imageIDs = { R.drawable.pic01, R.drawable.pic02, R.drawable.pic03, R.drawable.pic04, R.drawable.pic05, R.drawable.pic06, R.drawable.pic07, R.drawable.pic08, R.drawable.pic09, R.drawable.pic10, R.drawable.pic11, R.drawable.pic12, R.drawable.pic13, R.drawable.pic14, R.drawable.pic15, R.drawable.pic16, R.drawable.pic17, R.drawable.pic18, R.drawable.pic19, R.drawable.pic20, R.drawable.pic21, R.drawable.pic22, R.drawable.pic23, R.drawable.pic24, R.drawable.pic25, R.drawable.pic26, R.drawable.pic27, R.drawable.pic28, R.drawable.pic29, R.drawable.pic30, R.drawable.pic31, R.drawable.pic32, R.drawable.pic33, R.drawable.pic34, R.drawable.pic35, R.drawable.pic36 }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.displayview); Gallery gallery = (Gallery) findViewById(R.id.gallery1); gallery.setAdapter(new ImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { //---display the images selected--- ImageView imageView = (ImageView) findViewById(R.id.image1); imageView.setImageResource(imageIDs[position]); } }); } public class ButtonPress extends Activity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.displayview); final Button button = (Button) findViewById(R.id.bigpic); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click setContentView(R.layout.webviews); WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl("file:///android_asset/index.html"); } }); } } public class ImageAdapter extends BaseAdapter { private Context context; private int itemBackground; public ImageAdapter(Context c) { context = c; //---setting the style--- TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); itemBackground = a.getResourceId( R.styleable.Gallery1_android_galleryItemBackground, 0); a.recycle(); } //---returns the number of images--- public int getCount() { return imageIDs.length; } //---returns the ID of an item--- public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } //---returns an ImageView view--- public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(context); imageView.setImageResource(imageIDs[position]); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setLayoutParams(new Gallery.LayoutParams(150, 120)); imageView.setBackgroundResource(itemBackground); return imageView; } } } ************************************************************************************************* I have added the section: ************************************************************************************************** public class ButtonPress extends Activity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.displayview); final Button button = (Button) findViewById(R.id.bigpic); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click setContentView(R.layout.webviews); WebView wv = (WebView) findViewById(R.id.webview1); wv.loadUrl("file:///android_asset/index.html"); } }); } } ******************************************************************************************** So When the button (bigpic) is pressed on (displayviews) xml file, it should load in a web broweser index.html from my asset directrory. The button displays, but when I press it, nothing happens, so I must be doing something wrong. I understand what that bit of code does, but can't work out how to make that bit of code as part of the running activity, as it doesn't seem to be? I also understand that under the 3 lines under "// Perform action on click" is where I would setContentView to the layout of my what my big picture would look like, and after that i would use my start activity, but I need to take accross to the new activty the variable 'position', how do I do that? -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en