我已經制作了一個簡單的按鈕,它在EditText中添加數字「1」。EditText使用按鈕添加文本時水平滾動
下面是XML代碼
<EditText
android:id="@+id/edittext1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:onClick="Btn1"
/>
和Java代碼
public void Btn1(View v){
EditText edittext1 = (EditText) findViewById(R.id.edittext1);
String getText = edittext1.getText().toString();
show_results.setText(getText+"1");
}
當我在寫EditText
與鍵盤,它會自動滾動水平和顯示的最後一個字符。但是當我按下按鈕時,它會添加文本,但不會滾動(所以只有第一個字符可見)。
有沒有解決方案?
要滾動查看? – Naddy
@Naddy它不是一個視圖。這是EditText – Enve
改正你的基本隊友。 EditText擴展了擴展View的TextView。無論如何,你想滾動EditText?這對我來說不是很清楚。 – Naddy