問題は、4 つの edittext フィールド (数値) のセットと、結果が 2 列に表示されるテーブル レイアウトがあることです。テーブル レイアウトの値は、すべての edittext 値が使用される数式によって計算されます。edittext フィールドに値を入力したときに、テーブル内の回答を動的に更新したいと考えています。出来ますか?もしそうなら、サンプルコードで光を当ててください。
そして、テーブルは別のアクティビティにあります。
テキストコードを編集
al_e.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
if((al<15)|(al>50)|al_e.getText().toString().length()==0){
invalid=1;
//al_e.setText(null);
Toast.makeText(getApplicationContext(),"Please enter a valid input\nRange [15mm,50mm]", Toast.LENGTH_SHORT).show();
}
}
});
画面のスクリーンショット。
テーブル レイアウトは、tabhost の setcontent として設定されます。
tabhost のカスタム addtab メソッド
private void addTab(String label, String tag, Drawable drawable, Intent intent) {
TabHost.TabSpec spec = mTabHost.newTabSpec(tag);
spec.setIndicator(createTabIndicator(label, drawable));
spec.setContent(intent);
intent.putExtra("AL", al);
intent.putExtra("K1", k1);
intent.putExtra("K2", k2);
intent.putExtra("ALC", al_const);
intent.putExtra("DR", dr);
intent.putExtra("INVALID", invalid);
mTabHost.addTab(spec);
}
タブホスト アクティビティで次のように実装します。
mTabHost=(TabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(getLocalActivityManager());
addTab("SRK/T", TAG_1, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(Second.this, Srkt_x.class));
addTab("SRK II", TAG_2, createTabDrawable(R.drawable.ic_tab_eye_unselected),new Intent(Second.this, Srk2_x.class));
addTab("BINKHORST", TAG_3, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(Second.this, Binkhorst_x.class));
addTab("HOLLADAY", TAG_4, createTabDrawable(R.drawable.ic_tab_eye_unselected), new Intent(Second.this, Holladay_x.class));
テーブル アクティビティは、srkt_x、srkt_2、holladay_x、binkhorst_x アクティビティで、tabhost のコンテンツとして設定します
実際、タブに edittext フィールドを実装し、タブのコンテンツをテーブル レイアウトとして設定しました。そのため、edittext フィールドを更新するときに、edittext のすぐ下にあるテーブル レイアウト フィールドを更新する必要があります。
PS:下手な画像編集失礼します