我想知道如何在输入字段中将此颜色(atm blue"将Phonenumber设置为伙伴")改为橙色,如下所示: 颜色:#FF9900
有谁知道怎么做?
修改
我这样定义了我的风格:
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:windowTitleStyle">@style/DialogWindowTitle</item>
</style>
这是DialogWindowTitle样式:
<style name="DialogWindowTitle_Holo">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">@android:style/TextAppearance.Holo.DialogWindowTitle</item>
</style>
<style name="DialogWindowTitle" parent="@style/DialogWindowTitle_Holo">
<item name="android:textAppearance">@style/TextAppearance.DialogWindowTitle</item>
<item name="android:textColor">@drawable/actionbar_background</item>
</style>
<style name="TextAppearance.DialogWindowTitle" parent="android:TextAppearance.Holo.DialogWindowTitle">
<item name="android:textColor">@drawable/actionbar_background</item>
</style>
我有以下活动:
public class SettingsActivity extends PreferenceActivity {
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
}
}
这是我的settings.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="@string/sectionTwoTitle" >
<EditTextPreference
android:title="@string/setPhoneNumber"
android:summary="@string/setPhoneNumberSum"
android:key="phoneNumber"/>
</PreferenceCategory>
</PreferenceScreen>
但这不起作用。有什么想法吗?
答案 0 :(得分:1)
这是一个很好的教程(关于样式对话框) http://blog.supenta.com/2014/07/02/how-to-style-alertdialogs-like-a-pro/
OR (上次修改) 您可以使用自定义对话框: 1 - 创建对话框布局:
customDialog.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/app"
android:layout_toRightOf="@+id/app"
android:layout_toEndOf="@+id/app"
android:background="#00ff0700">
<LinearLayout
android:orientation="vertical"
android:background="@drawable/bg_parent_rounded_corner_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/details"
android:id="@+id/textView6"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_margin="10dp"
android:layout_row="0"
android:layout_column="0"
android:autoText="false"
android:textColor="#0061C2" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/nom"
android:textSize="18dp"
android:id="@+id/nom"
android:layout_row="1"
android:layout_column="0"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/prenom"
android:textSize="18dp"
android:id="@+id/prenom"
android:layout_row="2"
android:layout_column="0"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/specialite"
android:textSize="18dp"
android:id="@+id/specialite"
android:layout_row="4"
android:layout_column="0"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/numero"
android:textSize="18dp"
android:id="@+id/num_tel"
android:layout_row="3"
android:layout_column="0"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/adresse"
android:textSize="18dp"
android:id="@+id/adresse"
android:layout_row="5"
android:layout_column="0"
android:layout_below="@+id/specialite"
android:layout_marginLeft="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dispo"
android:textSize="18dp"
android:id="@+id/tvDispo"
android:layout_row="1"
android:layout_column="0"
android:layout_marginLeft="10dp"
android:visibility="visible" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/heures"
android:textSize="18dp"
android:id="@+id/tvHeures"
android:layout_row="2"
android:layout_column="0"
android:layout_marginLeft="10dp"
android:visibility="visible" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/listRdvDispo"
android:textSize="18dp"
android:id="@+id/tvJours"
android:layout_row="3"
android:layout_column="0"
android:layout_marginLeft="10dp"
android:visibility="visible" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/OK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/OK"
android:background="@drawable/btn_back_2"
android:textColor="#ffffffff"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Appeler"
android:background="@drawable/btn_back_2"
android:id="@+id/App"
android:textColor="#ffffffff"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/surCarte"
android:textColor="#ffffffff"
android:background="@drawable/btn_back_2"
android:id="@+id/Car"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
之后转到您的活动并添加:
public void afficherDialogue(){
dialog3 = new Dialog(MainActivity.context);
dialog3.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog3.setContentView(R.layout.custom_dialog);
Cursor medecin = MainActivity.db.lireMedecin();
((TextView) dialog3.findViewById(R.id.num_tel)).setText("phone number");
((TextView) dialog3.findViewById(R.id.nom)).setText("name");
((TextView) dialog3.findViewById(R.id.prenom)).setText("last name");
((TextView) dialog3.findViewById(R.id.adresse)).setText("addresse");
Button ok = (Button) dialog3.findViewById(R.id.OK);
Button App = (Button) dialog3.findViewById(R.id.App);
Button Car = (Button) dialog3.findViewById(R.id.Car);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog3.dismiss();
}
});
App.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//do something
dialog3.dismiss();
}
});
Car.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//do something
dialog3.dismiss();
}
});
dialog3.show();
}
这是我的对话框看起来
的方式答案 1 :(得分:0)
只需致电setTitleColor(int textColor)
;简短而精确。