처음에는 TextView
이 비어 있으며 그 이후에 텍스트를 업데이트해야합니다. TextView
.TextView의 텍스트 업데이트
업데이트 :
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="Test.test.MainActivity">
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="42dp"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_marginRight="0dp"
android:text="@string/Title1"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="42dp"
app:layout_constraintRight_toRightOf="parent"
android:textSize="30dp" />
</android.support.constraint.ConstraintLayout>
완전 활동 : 그것은 작동하지 않습니다
public class MainActivity extends AppCompatActivity
{
TextView textView2 = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_main);
textView2 = (TextView)findViewById(R.id.textView2);
///do something...
textView2.setText("dad");// instead "dad" i put string value.
} catch (Exception e) {
e.printStackTrace();
}
}
}
.
누군가가 아이디어가 있습니까?
감사합니다,
탈
왜 'textView1.setText ("dad");'를 시도하지 않습니까? 그게 완전히 다른 textview – Doomsknight
의 텍스트를 설정하고있다 내가 혼란스러워하고, 질문을 업데이 트 – tal
레이아웃 XML을 업로드하고 activitly 완전히 – Bek