2012-05-23 8 views
0

경고 대화 상자에서 세 개의 버튼을 어떻게 팽창시켜야하는지 묻는 것이 필요합니다. 기본적으로 목록보기를 사용할 수 있으며 사용자가 목록 항목을 길게 누르면 알림 대화 상자가 나타나야하고 대화 상자에는 편집, 삭제 및 기타 버튼이 있어야하며 버튼을 누르면 작업이 수행되어야합니다. 정말 감사하겠습니다. 누군가가 내가 buttons.Thanks경고 대화 상자에서 확대보기

답변

1

을 당신은에 AlertDialog를 사용하는 경우 3 개의 버튼을 추가 할 수 있습니다.

new AlertDialog.Builder(this) 
    .setPositiveButton("Edit", new OnClickListener() 
     { 
      // Code Here 
     }) 
    .setNeutralButton("Delete", new OnClickListener() 
     { 
      // Code Here 
     }) 
    .setNegativeButton("Delete", new OnClickListener() 
     { 
      // Code Here 
     }) 
    .create() 
    .show(); 
0

당신은 너무 마찬가지로, 상황에 맞는 메뉴를 사용할 수 있습니다

final OnCreateContextMenuListener occml = new OnCreateContextMenuListener() { 

    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) 
    { 
     AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; 
     menu.setHeaderTitle(pi.getBrowserIdentifier()); 
     menu.add(R.id.actionBarMenu_Settings, R.string.one, 1, getString(R.string.one)); 
     menu.add(R.id.actionBarMenu_Settings, R.string.two, 2, getString(R.two)); 
     menu.add(R.id.actionBarMenu_Settings, R.string.three, 3, getString(R.string.three)); 
    }; 
_listView= (ListView) findViewById(R.id.list); 
_listView.setOnCreateContextMenuListener(occml); 
0

을 난, 이런 식으로 일을하고도 할 수 있습니다

AlertDialog.Builder builder = new AlertDialog.Builder(this); 
    builder.setTitle("Seçenekler"); 
    builder.setAdapter(/*#your adapter here#*/, new DialogInterface.OnClickListener() { 

         @Override 
         public void onClick(DialogInterface dialog, int which) { 

//do something 
         } 
        }); 
0

다음 코드 캡쳐 뷰 재정의 setView에서 사용자 정의 대화 상자 클래스는 경고 대화 상자를 확장합니다.

class example extends Activity{ 


private void onClick_show_dialog(View v) 
{ 


    LayoutInflater lainf = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    final View frmFileSystem = lainf.inflate(R.layout.dlg_filesystem, (ViewGroup) findViewById(R.id.lilaFileSystem)); 

    dlg_filesystem = new DlgFileSystem(this); 
    dlg_filesystem.setView(frmFileSystem); 
    dlg_filesystem.setCancelable(true); 
    dlg_filesystem.setButton('aceptar' , new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) 
    { 
     alert(dlg_filesystem.prueba); 
    }}); 
    dlg_filesystem.setButton2('cancelar' , new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) 
    { 
    }}); 
    dlg_filesystem.show(); 
} 

} 

public class DlgFileSystem extends AlertDialog{ 
public String prueba; 
private Context context; 
private View frmFileSystem; 

public DlgFileSystem(Context context) 
{ 
    super(context); 
    this.context = context; 
} 

@Override 
public void setView(View frmFileSystem) 
{ 
    super.setView(frmFileSystem); 
    this.frmFileSystem = frmFileSystem; 
    TextView txprueba = (TextView)frmFileSystem.findViewById(R.id.txPrueba); 
    txprueba.setText("adios"); 
} 
} 
관련 문제