Q1. Bạn cần phải thổi phồng hoặc tùy chỉnh và tạo ra một phong cách và áp dụng đối với AlertDialog
Heres cách bạn thổi phồng một cách bố trí và áp dụng nó vào AlertDialog
LayoutInflater li = LayoutInflater.from(ctx);
View view = li.inflate(R.layout.formatted_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.setTitle("Formatted");
builder.setView(view);
xác định tất cả các định dạng và phong cách cần thiết trong cách bố trí mà bạn chỉ định.
Bạn có thể truy cập vào TextView cụ thể được định nghĩa trong bố trí sử dụng thổi phồng Xem ví dụ:
LayoutInflater li = LayoutInflater.from(ctx);
View view = li.inflate(R.layout.formatted_dialog, null);
TextView label=(TextView)view.findViewById(R.id.i_am_from_formatted_layout_lable);
Q2. android:textColorLink="#FF00FF"
có thể được sử dụng để chỉ định màu của liên kết.
EDIT:
Mẫu bố trí lưu lại dưới dạng res/layout/link.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="http://www.google.com"
android:autoLink="web"
android:textColorLink="#FF00FF"
/>
</LinearLayout>
Trong onCreate của bạn() hoặc nơi hoặc bất cứ khi nào bạn muốn gọi AlertDialog
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.link, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Formatted");
builder.setView(view).create().show();
TextView text=(TextView) findViewById(R.id.text);
thay thế this
bằng đối tượng bối cảnh nếu bạn đang gọi từ một số phương thức khác.
Tôi có một số nghi ngờ. Bố cục format_dialog sẽ như thế nào? Sau đó, tôi nên thêm nội dung của mình như thế nào? Và tôi nên chỉ định 'android: textColorLink' ở đâu? – Vivek
Đã thêm mẫu. hy vọng điều này sẽ cho bạn ý tưởng rõ ràng. – Shardul
bạn có thể cho tôi biết, làm thế nào để sử dụng kiểu chữ trong AlertDialog –