Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 有人能指导如何设置搜索按钮吗_Android_Android Listview_Imageview - Fatal编程技术网

Android 有人能指导如何设置搜索按钮吗

Android 有人能指导如何设置搜索按钮吗,android,android-listview,imageview,Android,Android Listview,Imageview,我正在开发一个壁纸应用程序。在里面我有100多张图片。我正在使用两个按钮将图像更改为下一个图像并向后。现在我想使用第三个按钮,它将打开可绘制图像名称的完整列表,该列表将上下移动。如果我选择了所需的图像名称,那么它将打开该图像。 此列表顶部还有两个按钮,一个用于转到图像,另一个用于取消。下面是它的样子: 这是我的XML布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http

我正在开发一个壁纸应用程序。在里面我有100多张图片。我正在使用两个按钮将图像更改为下一个图像并向后。现在我想使用第三个按钮,它将打开可绘制图像名称的完整列表,该列表将上下移动。如果我选择了所需的图像名称,那么它将打开该图像。 此列表顶部还有两个按钮,一个用于转到图像,另一个用于取消。下面是它的样子:

这是我的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:gravity="fill" 
    android:orientation="vertical" 
    android:weightSum="100" >
  <ImageView 
    android:id="@+id/idImageViewPic"
    android:layout_width="match_parent"
    android:layout_height="0dp" 
    android:layout_weight="100"
    android:adjustViewBounds="true" 
    android:background="#66FFFFFF" 
    android:maxHeight="91dip" 
    android:maxWidth="47dip"
    android:padding="10dip" 
    android:src="@drawable/r0" /> 
 <LinearLayout android:id="@+id/linearLayout1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" >
 <Button 
     android:id="@+id/bprev"
     android:layout_width="0dp" 
     android:layout_height="wrap_content"
     android:layout_weight="1"
     android:text="Back" >
     </Button> 
 <Button
      android:id="@+id/bnext"
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1"
      android:text="Next" > 
      </Button>
    </LinearLayout>
  </LinearLayout> 

如果我使用XML中的另一个按钮,那么我应该在主活动中编写什么?有更好的方法吗?

我想,你能做的是:

您拥有可绘制/位图设备的列表

Drawable myDrawable = getResources().getDrawable(R.drawable.yourImage); // Drawables
Bitmap myLogo = ((BitmapDrawable) myDrawable).getBitmap();
imageView.setImageBitmap(myLogo);
如果从设备中选择了图像,或者您有路径:

Uri selectedImage = convert your image path into URI ;
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImage);
userImg.setImageBitmap(bitmap); 
编辑:

最后,但在这条线之前

ImageViewPic.setImageResource(images[currentImage]) ;
添加此行:

Drawable myDrawable = getResources().getDrawable(R.drawable.yourImage); // Drawables
Bitmap currentImage= ((BitmapDrawable) myDrawable).getBitmap();
然后加上

ImageViewPic.setImageResource(images[currentImage]) ;

谢谢你的回答,先生。我如何在我的主要活动中使用它。你能编辑我的主要活动吗?请看编辑部分,我不是先生,我只是stackoverFlow的一个小贡献者。
ImageViewPic.setImageResource(images[currentImage]) ;