简体   繁体   English

如何使TextView可点击

[英]How to make textview clickable

Can anyone help me please? 谁能帮我吗?

I want my code to work in a way where when I click on a textview in must take me to a new activity. 我希望我的代码以某种方式工作,当我单击文本视图时,必须带我进行新的活动。

// Create an Intent to launch ExampleActivity
        Intent intent = new Intent(context, BrowserActivity.class);
        intent.setData(Uri.parse(ListNewsActivity.news.get(0).getLink()));
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                intent, 0);

        // Get the layout for the App Widget and attach an on-click listener
        // to the button
        RemoteViews views = new RemoteViews(context.getPackageName(),
                R.layout.widget1);
        views.setOnClickPendingIntent(R.id.button, pendingIntent);
TextView textView = (TextView) this.findViewById(R.id.textView1);
textView.setOnClickListener(new OnClickListener() {
    @Override           
    public void onClick(View v) {
        Intent int = new Intent(this, NewActivity.class);
        startActivity(int);
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM