現在Buttonによる画面の切り替えをTablayoutによる切り替えに変更しております。
Buttonでは
<Button
android:id="@+id/test1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:tag="1"
android:text="テスト1"
></Button>
のようなものを複数個設置して
Javaでは
public void onClickProc(final View v) {
testappl.intListNo = Integer.parseInt(v.getTag().toString());
this.getListRss(testappl.intListNo, true, false);
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Activityが起動する時
@Override
public void onStart() {
this.findViewById(R.id.test1).setOnClickListener(
new OnClickListener() {
public void onClick(final View v) {
testappl.this.onClickProc(v);
}
});
}
となっておりButtonを押すと上の
public void onClickProc(final View v) 部分でxmlのタグを取得してきて実行クラス以下のJavaで画面の切り替えを行っておりました。
今回これをTabによる切り替えに書き換えたいのですが、
public void onClickProc(final View v) 部分を
public void onTabSelected(final View v){
Object obj = v.getTag();
String objStr = obj.toString();
int value = new Integer(objStr).intValue();
testappl.intListNo = value; this.getListRss(testappl.intListNo, true, false); }
に書き換え実行クラス以下の部分をどう書けば良いのか悩んでおります。
解説、ヒントのほどよろしくお願いいたします。
あなたの回答
tips
プレビュー