话不多说,直接上码:xml文件,简单的线性布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center">

    </LinearLayout>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button3"
        android:text="下一张"
        android:layout_gravity="right" />

    <ImageView
        android:id="@+id/p_w_picpath1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/cat"
        android:scaleType="fitCenter"
    />
</LinearLayout>

效果图wKioL1VytXzTTzDrAAEQNyEvK9g851.jpg




package com.example.administrator.myapplication;

import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;

/**
 * Created by Administrator on 2015/6/6.
 */
public class Textp_w_picpathActivity extends Activity{
    //定义一个访问照片的数组
    int[] p_w_picpaths=new int[]{
            R.drawable.cat,
            R.drawable.dog,
            R.drawable.happen,
            R.drawable.hashiqi,
            R.drawable.what,
            R.drawable.name,
            };
//定义默认显示的照片
    int currentImg=2;
       protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏TITLE
        setContentView(R.layout.p_w_picpathview);
        final ImageView p_w_picpath1=(ImageView)findViewById(R.id.p_w_picpath1);
        final Button next=(Button)findViewById(R.id.button3);
              //定义查看下一张图片的监听器
        next.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //控制Image View显示下一张照片
                p_w_picpath1.setImageResource(
                        p_w_picpaths[++currentImg % p_w_picpaths.length]
                );
            }
        });


}}