我使用下面的代码来创建自定义首选项。xml布局文件有一个Button、EditText和TextView。这个自定义布局出现在一个带有"OK“和"Cancel”按钮的Alert中。这一切都运行得很好。
我想在"OK“和"Cancel”按钮旁边添加第三个按钮(中性按钮),我已经尝试过AlertBuilder类,但不知道如何将自定义布局和中性按钮合并在一起。
如何做到这一点?
目前有...
public class MelsMessage extends DialogPreference {
Button bMessage;
EditText eM
OK.in Java创建一个扩展JPanel的类,比在主class.for示例中使用它简单得多:
public class MyPanel extends JPanel(){
public MyPanel() {
addField();
}
private void addField() {
JTextField field = new JTextField("Panel");
add(field);
}}
然后在其中使用另一个类
public class Main(){
MyPanel panel = new MyPanel();
我遵循给出的例子,他展示了如何实现我正在寻找的目标。我创建了一个定制的EditText类:
public class LinedEditText extends AppCompatEditText {
private Rect mRect;
private Paint mPaint;
// we need this constructor for LayoutInflater
public LinedEditText(Context context, AttributeSet attrs) {
super(context, attrs);
mRect = new Rect(