먼저 NOOb인데 모두에게 감사의 말을 전하고 질문과 답변을 읽으면 많은 것을 배웠습니다. 나는 최종 사용자에게 많은 양의 텍스트를 전달하려고 노력하고 있으며, 새로운 클래스와 .xml 파일로이를 수행 할 수있는 동안 이것은 번거로워지고있다. 나는 단지 텍스트 문자열의 특정 집합에 대한 단일 XML 레이아웃을 가지고 단지 @string/?????를 변경하여 응용 프로그램을 라이닝하는 줄 알았는데 버튼을 통해 onclick 및 setText하지만 xml 파일에서 @string의 초기 값을 변경할 수 없다는 것을 알게되었습니다. 질문은 사실입니까? 그리고 더 효율적인 방법이 즉 (설정 안드로이드 : var에 텍스트 및 자바에서 특정 문자열을 var에 설정) 또는 각 문자열에 대한 새로운 XML 레이아웃이 필요합니까? (당신이 저에게 묻는다면 그것은 많은 낭비입니다) 그리고 약간의 통찰력, 분당 5 단락과 성장과 함께 이번에 약 250 다른 문자열이 있습니다.scrollView에 표시되는 문자열 값 변경
여기 내 코드입니다. 나는 그것이 내가 나중에 사용하기 위해 장소에 보관하고 싶은 다른 클래스의 Aso1를 호출 그래서 다음 온 클릭 에서이 텍스트보기 라인을 제거 할 때 먼저 자바
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Monlt extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.monolt);
final MediaPlayer buttonsound = MediaPlayer.create(Monlt.this, (R.raw.buttonclick));
Button button1 = (Button) findViewById(id.button1);
Button button2 = (Button) findViewById(id.button2);
Button button3 = (Button) findViewById(id.button3);
Button button4 = (Button) findViewById(id.button4);
Button button5 = (Button) findViewById(id.button5);
Button button6 = (Button) findViewById(id.button6);
Button button7 = (Button) findViewById(id.button7);
Button button8 = (Button) findViewById(id.button8);
Button button9 = (Button) findViewById(id.button9);
Button button11 = (Button) findViewById(id.button11);
Button button12 = (Button) findViewById(id.button12);
Button button13 = (Button) findViewById(id.button13);
Button button14 = (Button) findViewById(id.button14);
Button button15 = (Button) findViewById(id.button15);
Button button16 = (Button) findViewById(id.button16);
Button button17 = (Button) findViewById(id.button17);
Button button18 = (Button) findViewById(id.button18);
Button button19 = (Button) findViewById(id.button19);
Button button21 = (Button) findViewById(id.button21);
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
buttonsound.start();
final TextView mview = (TextView) findViewById(R.id.solayout2);
mview.setText("mono1"); //this was my first string to pass
startActivity(new Intent("com.nvar.Sorders.Mono.ASO1"));
}
});
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
buttonsound.start();
startActivity(new Intent("com.nvar.Sorders.ASO1"));
final TextView mview = (TextView) findViewById(R.id.solayout2);
mview.setText("@string/mono2");/this is the second string to pass
}
});
`
의
조각은 지금이 코드는 작동합니다. Aso1 자바 코드 ` 패키지 com.nvar.Sorders.Mono; 다음
`
및
import com.nvar.Sorders.R;
import android.app.Activity;
import android.os.Bundle;
public class Aso1 extends Activity {
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.solayout2);
}
}
이 문제에 어떤 도움이 크게 감사하고, 자바에 "멍청한 놈"를 기억 될 것이다
`
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/solayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mview"/>
<!-- android:text="@string/monoaso1"/>
-->
<!-- this is were i was playing with the strings />
-->
</LinearLayout>
</ScrollView>
` 첫 번째 XML/안드로이드! 그래서 내가 볼 수 있거나보아야 만하는 표본이 있다면 주저하지 말고 저를 머리에 쓰러 뜨리고 저를 올바른 방향으로 향하게하십시오. 나는 독서를 꺼리지 않는다. 다시 한 번 감사드립니다.
의 스크롤 단락처럼 보이는 뭔가를해야합니다 : 다음 코드는 값을 업데이트하기 위해이 같은 작업을 수행 할 수 있습니다 클래스 및 xml을 누른 다음에 setText를 사용하면 런타임 오류가 발생합니다. 해당 줄을 제거하면 응용 프로그램은 다음 클래스와 새 XML로 진행합니다. 나는 그 해답을 이해하지 못하거나 그 질문을 설명하지 못했습니다. 첫 번째 클래스의 onClick에서 선택한 옵션에 따라 다른 문자열을 표시하려는 문자열 값으로 변경하지 않으려합니다. – Madtec
죄송합니다. xml 문자열에 현지화 링크를 추가하는 것을 잊었습니다. 텍스트를 변경하는 코드도 업데이트했습니다. 그래서 xml에 두 개의 sting 값을 선언해야하고'res.getString (R.string.string_id)'를 사용하여 문자열 값을 얻을 수 있습니다. –