2012-09-04 148 views
-1

我正在尋找一個圖像按鈕,它像XML中的微調器一樣工作。我發現了一些關於這方面的信息,但沒有像以後那樣。所以當我點擊一個圖像視圖時,一個微調框會出現一個列表以供選擇,如果可以通過的話,它將來自我的數據庫。我發現它沒有做任何事情像旋鈕一樣的圖像按鈕

https://groups.google.com/forum/?fromgroups=#!topic/android-developers/KeUxBt4SJLw

我希望能在我的活動10個圖像按鈕具有爲每一個微調。 當用戶從微調列表中選擇一個對話框會出現(我會稍後嘗試後,我可以先編碼)。

任何幫助將幫助謝謝

 package com.spinn; 

     import android.app.Activity; 
     import android.os.Bundle; 
     import android.widget.ArrayAdapter; 
     import android.widget.Button; 
     import android.widget.Spinner; 

     public class MainActivity extends Activity { 

     @Override 
     public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
     this, R.array.array_name, android.R.layout.simple_spinner_item); 
     adapter.setDropDownViewResource(    
     android.R.layout. simple_spinner_dropdown_item); 

     Spinner s = (Spinner) findViewById(R.id.unique_id); 
     s.setAdapter(adapter); 

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

<Button 
    android:id="@+id/unique_id" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="30dp" 
    android:background="@drawable/c3" /> 

    </RelativeLayout> 

回答

0

爲什麼不使用紡紗用設置的背景圖像按鈕的背景是什麼?這應該做的伎倆...

+0

我做了這個,但它什麼也沒做 –