`
张玉龙
  • 浏览: 725254 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

Android textview 点击事件

 
阅读更多
public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        TextView study_id = (TextView)findViewById(R.id.study_id); 
        study_id.setOnClickListener(
        new OnClickListener(){
			@Override
			public void onClick(View arg0) {
				Toast toast = Toast.makeText(getApplicationContext(), "I am Clicked", Toast.LENGTH_LONG);//提示被点击了
				toast.show();
			}
        });
    }
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView android:layout_width="fill_parent" android:id="@+id/study_id" android:text="开始学习" android:layout_weight="2" android:layout_height="wrap_content"></TextView>
    <TextView android:layout_width="fill_parent" android:id="@+id/plan_id" android:text="学习计划" android:layout_weight="2" android:layout_height="wrap_content"></TextView>
    <TextView android:layout_width="fill_parent" android:id="@+id/about_id" android:text="关于" android:layout_weight="2" android:layout_height="wrap_content"></TextView>
</LinearLayout>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics