문제가 있습니다. 단추 이외의 다른 활동에서 EditText 필드의 텍스트를 변경하고 싶습니다.버튼으로 편집 문구 변경
다음<EditText
android:id="@+id/articlename"
android:layout_width="278dp"
android:layout_height="75dp"
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:inputType="textMultiLine"
android:text="Name of article"
android:textColor="#FFF"
android:textSize="22dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginStart="16dp"
android:layout_marginTop="108dp"
android:background="@drawable/circle"
android:onClick="onClicknews"
android:text="news\n(click me)"
android:textColor="#FFFF"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
내 MainActivity 버튼은 다음과 같습니다 :
<EditText
android:id="@+id/news"
android:layout_width="350dp"
android:layout_height="407dp"
android:layout_marginBottom="23dp"
android:layout_marginEnd="11dp"
android:layout_marginStart="11dp"
android:clickable="false"
android:cursorVisible="false"
android:ems="10"
android:focusable="false"
android:inputType="textMultiLine"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
I 다음 글고 치기가
public void onClicknews(View v) {
Intent intent = new Intent(getApplicationContext(), NewsActivity.class);
String titel1 = "Trumps brutales Kalkül";
EditText news = (EditText) findViewById(R.id.news);
EditText article = (EditText) findViewById(R.id.articlename);
String s = article.getText().toString();
if (s.equalsIgnoreCase(titel1)){
news.setText("Hallo");
}
startActivity(intent);
}
그리고 여기 내 두 번째 XML 여기
내 주요 XML이다 비슷한 질문이 있다는 것을 알았지 만 솔로 션 중 어느 것도 나를 도왔습니다.
두 번째 활동의 의도에 값을 번들로 보내고 onCreate에서 해당 값을 추출하여 거기에 설정하는 것이 어떻습니까? 유스 케이스에 대한 자세한 정보를 제공하십시오 ... – kRiZ