<Button android:id="@+id/button1" android:text="blah blah">
텍스트를 android:text
안에 어떻게 가져 옵니까?버튼 내부 텍스트 가져 오기
<Button android:id="@+id/button1" android:text="blah blah">
텍스트를 android:text
안에 어떻게 가져 옵니까?버튼 내부 텍스트 가져 오기
Button btn = (Button)findViewById(R.id.button1);
String buttontext = btn.getText().toString();
희망이 도움이 될 것입니다.
로 문자를받습니다. 아래의 의견에 따라
Button button = (Button) findViewById(R.id.button1);
String yourText = (String)button.getText();
Button tv = (Button) findViewById(R.id.button1);
String buttonName = tv.getText().toString();
편집, 감사합니다 :).
TextView button1 = (TextView)findViewById(R.id.button1);
String text = button1.getText().toString();
Button mButton;
mButton=(Button)findViewById(R.id.button1);
String buttontext= mButton.getText().toString();
는 시도 strings.xml의에서 모든 문자열을 유지하는 (대신 하드 코딩 사방을)를 strings.xml의에서
<Button android:id="@+id/button1" android:text="@string/button1_label">
:
<string name="button1_label">blah blah</string>
다음을 사용하여 쉽게 텍스트를 가져올 수 있습니다.
Context.getString(R.string.button1_label)
자세한 내용은 here을 참조하십시오.
tv.getText(). toString(); 필수 –