A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

xml布局主要代码:
<TextView
                        android:id="@+id/tv"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:clickable="true"
                        android:text="helloWorld" />
                    <!-- 为TextView添加点击事件需设置 clickable="true" -->
MainActivity主要代码:
public class MainActivity extends Activity implements OnClickListener {
        private TextView tv;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.test);
                tv = (TextView)findViewById(R.id.tv);
                tv.setOnClickListener(this);
        }
        @Override
        public void onClick(View arg0) {
                Toast.makeText(this, "我是helloworld", 1).show();
        }
}

4 个回复

正序浏览
回复 使用道具 举报
哈哈哈哈哈哈哈哈哈哈哈哈
来自宇宙超级黑马专属苹果客户端来自宇宙超级黑马专属苹果客户端
回复 使用道具 举报
。。。。。。。。。。。
来自宇宙超级黑马专属苹果客户端来自宇宙超级黑马专属苹果客户端
回复 使用道具 举报
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马