答案 0 :(得分:2)
PreferenceActivity
您可以使用以下方式获取BACK箭头:
getActionBar().setDisplayHomeAsUpEnabled(true);
关于第二张图片:这是一个带单选按钮的自定义对话框。
答案 1 :(得分:1)
PreferenceActivity
设置创建一个返回箭头:
getActionBar().setDisplayHomeAsUpEnabled(true);
答案 2 :(得分:1)
以下是一个简单的示例,介绍如何创建一个与您展示的对话框类似的对话框:
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Context context = this;
String items[] = {"For all calls", "Only for SIP calls"};
new AlertDialog.Builder(context)
.setSingleChoiceItems(items, 1, null)
.setTitle("Use SIP calling")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
// Do something useful withe the position of the selected radio button
Toast.makeText(context, "The element " + selectedPosition + " was selected", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
})
.show();
}
}
如果您想要Lollipop前版本的 Material Design 对话框,可以使用此库: https://github.com/afollestad/material-dialogs(请参阅单一选项列表对话框)