0

別のダイアログボックス内にダイアログを表示したいのですが、正常に機能していますが、[追加]または[編集]ボタンをクリックしても応答がありません。以下のコードを投稿しました

    private Dialog myTextDialog(final String title) {
    final AlertDialog.Builder builder=new AlertDialog.Builder(this);

    builder.setView(getCurrentFocus());
    builder.setPositiveButton("ADD", new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            myAddCategory(title);
        }
    });
    builder.setNegativeButton("EDIT", new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            mAdapter = new MyExpandableListAdapter(MyGraphicalActivity.this, listOptionGroup, listOptionChild);
        }
    });
    return builder.create();
 }  

private Dialog myAddCategory(final String title) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);

    final View viewMessEdit = inflater.inflate(R.layout.add_category,(ViewGroup) findViewById(R.id.alertlayout));

    builder.setView(viewMessEdit);                  
   //viewMessEdit.setBackgroundResource(R.color.grayy);

    builder.setPositiveButton("ADD", new Dialog.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            final EditText savedText = ((EditText) viewMessEdit.findViewById(R.id.inputbox));   
            newcategory=savedText.getText().toString();
            newcategory = checkCategory(newcategory);
            if(newcategory!="null" && newcategory.length()>0)
            {            
            Pattern pattern;                         
            pattern=Pattern.compile("[A-Z | a-z]*");
            Matcher matcher=pattern.matcher(newcategory);       
                if(!matcher.matches()) 
                {               
                    myTextDialog(title).show();
                    Toast.makeText(getBaseContext(),"Invalid Category name!",Toast.LENGTH_LONG).show();
                }
                else
                {               
                    Intent addcategorylist_intent=new Intent(MyGraphicalActivity.this,addcategorylist.class);
                    startActivity(addcategorylist_intent);
                    Toast.makeText(getBaseContext(), "ADDED", Toast.LENGTH_SHORT).show();
                }
            }
            else
            {
                myTextDialog(title).show();
                Toast.makeText(getBaseContext(),"You Can not give Blank & already specified Category!",Toast.LENGTH_LONG).show();            
            }
        }
    });
    builder.setNegativeButton("CANCEL",new Dialog.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

        }             
    });

    return builder.create();
}
4

1 に答える 1

2

次のコードを変更します

builder.setPositiveButton("ADD", new OnClickListener() {

    public void onClick(DialogInterface dialog, int which) {
        myAddCategory(title);
    }
});

builder.setPositiveButton("ADD", new OnClickListener() {

    public void onClick(DialogInterface dialog, int which) {
        myAddCategory(title).show();
    }
});
于 2012-05-17T05:42:30.193 に答える