利用し始めて1ヶ月の初心者です。
現在カスタムビューでレイアウトを使い回しています。
カスタムレイアウト内にあるtextを設定する際のコードがmain.java内で複数になっており、見づらいので改善したいのですが、いい方法は無いでしょうか。
できれば一行で記述したいです。
初歩的な質問ですが、ご鞭撻よろしくお願いします。
java
1@Override 2 protected void onCreate(Bundle savedInstanceState) { 3 super.onCreate(savedInstanceState); 4 setContentView(R.layout.activity_otherwise); 5 6 TextView textView1 = (findViewById(R.id.table1).findViewById(R.id.textView3)); 7 textView1.setText(R.string.text1_1); 8 9 TextView textView2 = findViewById(R.id.textView2)); 10 textView2.setText(R.string.text1_2);
java
1public CustomLayout(Context context, AttributeSet attrs){ 2 super(context,attrs); 3 View layout = LayoutInflater.from(context).inflate(R.layout.custom_layout,this); 4 5 text = layout.findViewById(R.id.textView); 6
あなたの回答
tips
プレビュー