2012-11-20 54 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" 

它与我合作。

请注意,您的文字只能在横向模式下显示。