I have created a custom title for my AlertDialog box. But I have not been able to centre the message. It always comes left aligned.
TextView vehicle_no = (TextView) findViewById(R.id.vehicle_no);
String ScoreTitle = getResources().getString(R.string.AlertTitle);
AlertDialog.Builder alrtbuilder = new AlertDialog.Builder(this);
Context mContext = alrtbuilder.getContext();
LayoutInflater mLayoutInflater = LayoutInflater.from(mContext);
View mView = mLayoutInflater.inflate(R.layout.simple_dialog, null);
TextView mTextView = (TextView) mView.findViewById(R.id.title_text);
mTextView.setText(ScoreTitle);
The AlertDialog box has a positive and a negative button
alrtbuilder.setCustomTitle(mView);
alrtbuilder.setMessage(vehicle_no.getText().toString().toUpperCase()+" "+"?")
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
insert_timecard();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).show;