Android 将字体设置为alertdialog
我有一个alertdialog,我使用字体作为标题、消息和alertdialog的按钮。 问题是,标题和消息视图使用的是字体,而不是按钮? 为什么? 这是我的密码Android 将字体设置为alertdialog,android,android-alertdialog,typeface,Android,Android Alertdialog,Typeface,我有一个alertdialog,我使用字体作为标题、消息和alertdialog的按钮。 问题是,标题和消息视图使用的是字体,而不是按钮? 为什么? 这是我的密码 public boolean functionInQuestion(MissingParameters ... parameters) { Typeface myTypeFace = Typeface.createFromAsset(getAssets(),"fonts/hhh.ttf"); TextView mysi
public boolean functionInQuestion(MissingParameters ... parameters) {
Typeface myTypeFace = Typeface.createFromAsset(getAssets(),"fonts/hhh.ttf");
TextView mysite = new TextView(mainn.this);
TextView fbpage = new TextView(mainn.this);
TextView content5 = new TextView(mainn.this);
TextView Mytitle5 = new TextView(mainn.this);
mysite.setText("google");
fbpage.setText("fb");
Mytitle5.setText("google and facebook");
content5.setText("linka to google and facebook");
mysite.setTypeface(myTypeFace);
fbpage.setTypeface(myTypeFace);
content5.setTypeface(myTypeFace);
Mytitle5.setTypeface(myTypeFace);
AlertDialog.Builder builder = new AlertDialog.Builder(mainn.this);
builder.setView(content5);
builder.setCustomTitle(Mytitle5);
builder.setIcon(R.drawable.about);
builder.setPositiveButton(fbpage.getText(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// When LeftButton click, source implementing is put here.
String url = "http://www.facebook.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
builder.setNeutralButton(mysite.getText(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// When CenterButton click, source implementing is put here.
String url = "http://www.google.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
builder.show();
return false;
}
试试这个,它一定有用:)
对不起,我说不工作。。。但这是一个书写错误。。。。如果您使用的是否定按钮use
button button\u negative=(button)dialog.findViewById(android.R.id.button2),则它不起作用代码>
public boolean functionInQuestion(MissingParameters ... parameters) {
Typeface myTypeFace = Typeface.createFromAsset(getAssets(),"fonts/hhh.ttf");
TextView mysite = new TextView(mainn.this);
TextView fbpage = new TextView(mainn.this);
TextView content5 = new TextView(mainn.this);
TextView Mytitle5 = new TextView(mainn.this);
mysite.setText("google");
fbpage.setText("fb");
Mytitle5.setText("google and facebook");
content5.setText("linka to google and facebook");
mysite.setTypeface(myTypeFace);
fbpage.setTypeface(myTypeFace);
content5.setTypeface(myTypeFace);
Mytitle5.setTypeface(myTypeFace);
AlertDialog.Builder builder = new AlertDialog.Builder(mainn.this);
builder.setView(content5);
builder.setCustomTitle(Mytitle5);
builder.setIcon(R.drawable.about);
builder.setPositiveButton(fbpage.getText(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// When LeftButton click, source implementing is put here.
String url = "http://www.facebook.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
builder.setNeutralButton(mysite.getText(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// When CenterButton click, source implementing is put here.
String url = "http://www.google.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
Dialog dialog =builder.show();
Button button = (Button) dialog.findViewById(android.R.id.button1);
button.setTypeface(myTypeFace);
Button button2 = (Button) dialog.findViewById(android.R.id.button3);
button2.setTypeface(myTypeFace);
return false;
}