2012-11-20 55 views
0

我如何自定義顯示在IME動作buttton中的EditTextView文本。 我試圖使用setImeActionLabel,但它不起作用。Android - 自定義IME動作按鈕

public class TestIMEActivity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     LinearLayout layout = new LinearLayout(this); 
     layout.setOrientation(LinearLayout.VERTICAL); 
     LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); 
     final EditText ed1 = new EditText(this); 
     ed1.setSingleLine(true); 
     ed1.setImeActionLabel("test", 0); 
     layout.addView(ed1, params); 
     setContentView(layout); 
    } 
} 
+0

您試圖更改哪個標籤? [這個答案](http://stackoverflow.com/a/1541161/752320)可能是有用的。 – Geobits

回答

0

我試着動態設置它。嘗試將其設置在您的XML:

android:imeActionLabel="@string/myCustomActionLabel" 

它與我合作。

請注意,您的文字只能在橫向模式下顯示。