mat*_*d91 9 java android linkify
<TextView
android:text="123456789"
android:autoLink="phone">
</TextView>
Run Code Online (Sandbox Code Playgroud)
我想从代码中创建这个TextView,但是我遇到了无数的问题.
首先,我中途创建一个TextView并添加:
tw_phone.setAutoLinkMask(0x04);
Run Code Online (Sandbox Code Playgroud)
这导致了一个可点击的TextView,但是当你点击时,一个toast说"没有应用程序可以执行此操作"或类似的东西.我也尝试过
Linkify.addLinks(tw_phone, Linkify.PHONE_NUMBERS); //and .ALL
Run Code Online (Sandbox Code Playgroud)
但它给了我相同的结果.
当我决定在StackOverflow上询问时,我试图剥离我的代码,因为我使用Layouts(你永远不知道)的方式有问题,但现在我甚至无法使TextView可点击.在我看来,这是代码应该工作的代码,因为它只是我在代码中使用的更精简的版本.
TableLayout table = (TableLayout) findViewById(R.id.tableResult);
TableRow row = new TableRow(this);
TextView tw = new TextView(this);
tw.setText("123456789");
tw.setAutoLinkMask(Linkify.ALL);
row.addView(tw);
table.addView(row);
Run Code Online (Sandbox Code Playgroud)
有人可以写一个简单的小例子来创建一个TextView,给它一个数字作为文本然后允许用户点击它并选择他们想要打开数字的任何应用程序吗?如果你能指出我的代码中的错误,那将是很好的,但我宁愿直接得到答案.我尝试的东西取自其他StackOverflow问题和答案.
小智 9
TextView tv_contatti2 = new TextView(this); tv_contatti2.setText(contatti);
Linkify.addLinks(tv_contatti2, Linkify.PHONE_NUMBERS);
tv_contatti2.setLinksClickable(true);
Run Code Online (Sandbox Code Playgroud)
其中"contatti"的值为+39012345678,带有国际前缀
| 归档时间: |
|
| 查看次数: |
7039 次 |
| 最近记录: |