Q1. Трябва да раздуете или персонализирате и създадете стил и да приложите към AlertDialog
Ето как раздувате оформление и го прилагате към 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);
дефинирайте цялото форматиране и стилове, изисквани в указаното от вас оформление.
Можете да получите достъп до конкретен текстов изглед, дефиниран в оформлението, като използвате раздут изглед, т.е.
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"
може да се използва за определяне на цвета на връзката.
РЕДАКТИРАНЕ:
Примерно оформление, запазено като 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>
Във вашия onCreate() или където или когато искате да извикате 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);
заменете this
с контекстен обект, ако извиквате от друг метод.
person
Shardul
schedule
27.12.2010