xml文件:
<tableLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:stretchColumns="0,1,2" androID:orIEntation="vertical" tools:context=".MainActivity"> <tableRow androID:layout_wIDth="fill_parent" androID:layout_height="match_parent" androID:gravity="center"> <TextVIEw androID:ID="@+ID/ttv1" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_gravity="left" androID:text="切换卡1" /> <TextVIEw androID:ID="@+ID/ttv2" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_gravity="center" androID:onClick="qIEhuanka2" androID:text="切换卡2" /> <TextVIEw androID:ID="@+ID/ttv3" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_gravity="right" androID:onClick="qIEhuanka3" androID:text="切换卡3" /> </tableRow> <TextVIEw androID:ID="@+ID/ttv4" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:gravity="center"/> </tableLayout>
Java代码文件:
package com.example.qIEhuanka;import androID.os.Bundle;import androID.app.Activity;import androID.vIEw.Menu;import androID.vIEw.VIEw;import androID.vIEw.VIEw.OnClickListener;import androID.Widget.TextVIEw;public class MainActivity extends Activity { TextVIEw tv1,tv2,tv3,tv4; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); tv4 = (TextVIEw) findVIEwByID(R.ID.ttv4); tv1 = (TextVIEw) findVIEwByID(R.ID.ttv1); tv2 = (TextVIEw) findVIEwByID(R.ID.ttv2); tv3 = (TextVIEw) findVIEwByID(R.ID.ttv3); tv1.setonClickListener(new OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub tv4.setText("切换卡1"); } }); tv2.setonClickListener(new OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub tv4.setText("切换卡2"); } }); tv3.setonClickListener(new OnClickListener() { public voID onClick(VIEw v) { // Todo auto-generated method stub tv4.setText("切换卡3"); } }); } @OverrIDe public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }
实现效果图:
以上是内存溢出为你收集整理的切换卡草稿全部内容,希望文章能够帮你解决切换卡草稿所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)