¿Cómo inflar inflar dos diseños de la misma clase?

Tengo un ListView and I want to display the selected list content in a popup when I click on it in the view. How can I do this?

Aquí está mi código:

public class EventbyDate extends ListActivity {
    Context cont;
    private Runnable DateEventListThread;
    public String DateEventListThreadResponse;
    private ProgressDialog m_ProgDialog = null;
    public DateEventListAdapter DateEventList_adapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.eventsbydate);
        GetDateEventList();
        this.DateEventList_adapter =  new DateEventListAdapter(this,R.layout.eventsbydate_list,
        RoamMeo_Config.DateEventList);
        setListAdapter(this.DateEventList_adapter);
    }
    @Override
    public void onPause() {
        super.onPause();
        this.finish();
    }
    void GetDateEventList() {
        m_ProgDialog = ProgressDialog.show(EventbyDate.this, " Please wait",
        "Collecting Data..", true);
        DateEventListThread = new Runnable() {
            @Override
            public void run() {
                DateEventListThread = null;
                try {
                } catch (Exception e) {
                    e.printStackTrace();
                }
                runOnUiThread(returnResponse);
            }
        };
        Thread thread = new Thread(null, DateEventListThread, "DateEventListThread");
        thread.start();
    }
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        LayoutInflater inflater = (LayoutInflater)  EventbyDate.
        this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup,null,    
        false),300,400,true);

        pw.showAtLocation(findViewById(R.id.txt_start_date),  

        Gravity.CENTER, 0,0);


    }

    private Runnable returnResponse = new Runnable() {
        @Override
        public void run() {             
            try {
                if (DateEventListThreadResponse != null&& 

                        DateEventListThreadResponse.length() > 0) {
                    boolean check = 
                    XMLParsing.EventDate_List_Response(DateEventListThreadResponse);
                    if(check) {


                        DateEventList_adapter.notifyDataSetChanged();                       
                    } else {
                        Toast msg =   

                        Toast.makeText(EventbyDate.this,"No list... ",Toast.LENGTH_LONG);
                        msg.setGravity(Gravity.CENTER,   

                        msg.getXOffset() / 2,msg.getYOffset() / 2);
                        msg.show();
                    }
                }
                if (m_ProgDialog != null)
                m_ProgDialog.dismiss();
                m_ProgDialog = null;
            } catch (Exception e) {
                if (m_ProgDialog != null)
                m_ProgDialog.dismiss();
                m_ProgDialog = null;
            }           
        }
    };

    class DateEventListAdapter extends ArrayAdapter<SaveDateEventList> {
        ArrayList<SaveDateEventList> items;
        public DateEventListAdapter(Context context, int  

        textViewResourceId,
        ArrayList<SaveDateEventList> items) {
            super(context, textViewResourceId, items);
            this.items = items;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup 

        parent) {
            View v = convertView;
            final SaveDateEventList d = items.get(position);
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)   

                getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.eventsbydate_list, null);
            }
            if (!items.isEmpty()) {
                if (d != null) {
                    TextView start_date = (TextView) 

                    v.findViewById(R.id.txt_start_date);
                    start_date.setText(d.ev_start_date);

                    TextView start_time = (TextView) 

                    v.findViewById(R.id.txt_start_time);
                    start_time.setText(d.ev_start_time);

                    TextView poptext = (TextView)  

                    v.findViewById(R.id.poptext);
                    poptext.setText(d.ev_start_time);
                }
            }
            return v;
        }
    }
}

preguntado el 08 de noviembre de 11 a las 10:11

1 Respuestas

Puedes hacer algo como esto protected void onListItemClick(ListView l, View v, int position, long id) {YourObject o = l.getItemAtPosition(position);}. After that you have to set what ever you need to display in your pop-up screen via this obtained object.

respondido 08 nov., 11:15

But the popup screen itslf is showing on that list item click. How to set data into that popup window? that's my qn! @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); LayoutInflater inflater = (LayoutInflater) EventbyDate.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup,null, false),300,400,true); pw.showAtLocation(findViewById(R.id.txt_start_date), Gravity.CENTER, 0,0);} - Froyo

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.