gpt4 book ai didi

java - 带有 TextView As 链接的 Android 对话框

转载 作者:太空宇宙 更新时间:2023-11-04 13:19:59 25 4
gpt4 key购买 nike

大家好,我有一个关于 android 对话框的问题。我想做的是在对话框中设置几行描述,我可以做得很好,但最后我需要一个名为“查看更多”的链接,它将用户重定向到其他 Activity 。我对 android 很陌生,这些是我尝试做的第一件事,任何帮助都将不胜感激。我的代码 onStart()

protected void onStart()
{
super.onStart();

/*final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.main);
dialog.setTitle("About Service One");


Button button = (Button) dialog.findViewById(R.id.button12);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});

dialog.show();

最佳答案

protected void onStart()
{
super.onStart();

final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.main);
dialog.setTitle("About Service One");


Button button = (Button) dialog.findViewById(R.id.button12);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
TextView showMore= (TextView ) dialog.findViewById(R.id.tvShowMore);
showMore.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(getApplicationContext(),ShowMoreActivity.class);
startActivity(intent);
}
});
dialog.show();

}


And add in xml showmore TextView Which set text from string.xml
i.e <string name="show_more"><u>Show More </u></string> use this for set linkable text

main.xml

……

<TextView
android:id="@+id/tvShowMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_more"
android:textAppearance="?android:attr/textAppearanceMedium"
>
</TextView>

............

关于java - 带有 TextView As 链接的 Android 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33164614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com