ListView in einem Popup-Fenster

Ich gesucht habe um für ein paar Stunden jetzt und nicht in der Lage gewesen zu finden, irgend etwas, das behebt mein Problem. Ich habe eine Anwendung, wo ich einen pop-up-Fenster. Innerhalb dieses popup-Fenster möchte ich anzeigen, um eine Liste der Kontakte auf meinem Handy, dieses Teil habe ich zu arbeiten. Ich habe eine a-adapter erweitert ArrayAdapter und ich habe es Auffüllen der Liste mit den Handys die Kontakte.

Aber jetzt will ich, um zu interagieren mit diesen Kontakten, dh. klicken Sie auf ein und zeigen Sie die Kontakt-Informationen für den Benutzer. Ich füge einen OnItemClickListener() auf der Liste, aber es wird nie genannt. Ich habe versucht, die Zellen nicht Isoliertes, ich habe versucht, indem onClickListeners, um jedes Element, das bedeutet aber nicht geben, die highlights der Zellen. Ich bin steckengeblieben.

Unten ist der code, den ich verwenden, um den setup-ListView-Steuerelement und fügen Sie den onItemClick-listener, um die Liste anzuzeigen.

ListView contactList = (ListView) contentView.findViewById(R.id.contacts_list);
  ContactsProcessing processContacts = new ContactsProcessing();
  contactList.setAdapter(processContacts.getListAdapter());
  contactList.setItemsCanFocus(false);
  contactList.setFocusableInTouchMode(false);
  contactList.setOnItemClickListener(new OnItemClickListener() {

     @Override
     public void onItemClick(AdapterView<?> l, View v, int position, long id) {
        //TODO Auto-generated method stub
        //super.onListItemClick(l, v, position, id);
        Toast toast = new Toast(MainActivity.this);
        toast.setText("Item Clicked");
        toast.show();
        m_ButtonFeedback.hapticFeedback();
        Log.d("MainActivity", "Item Clicked");


     }
  });

In der gleichen pop-up-Fenster, ich habe auch einen exit-button. Es funktioniert, wie ich erwarte.

ImageButton exit = (ImageButton) contentView.findViewById(R.id.contacts_close_button);
  exit.setOnClickListener(new OnClickListener() {

     @Override
     public void onClick(View _v) {
        window.dismiss();

     }
  });

Hier ist meine Zelle XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:background="@android:color/transparent"
android:id="@+id/contact_cell_root" >

<TextView
    android:id="@+id/contact_cell_headerText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    android:paddingLeft="15dp"
    android:scrollbars="none"
    android:textColor="#29abe2"
    android:textSize="18sp"
    android:textStyle="bold"
    android:visibility="gone" />

<View
    android:id="@+id/contact_cell_header_divider" 
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:background="#29abe2"
    android:visibility="gone"/>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:background="@android:color/transparent"
    android:gravity="center"
    android:paddingRight="10dp"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/contact_cell_user_image"
        android:adjustViewBounds="true"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:scaleType="centerInside"
        android:src="@drawable/contact_default"
        android:focusable="false" />

    <LinearLayout 
        android:layout_width="0px"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:orientation="vertical"
        android:paddingBottom="5dp"
        android:paddingTop="5dp" >

        <TextView
            android:id="@+id/contact_cell_titleText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:ellipsize="end"
            android:singleLine="true"
            android:text="John Smith"

            android:textStyle="bold"
            android:textSize="16sp" 
            android:textColor="@android:color/black"/>

        <TextView
            android:id="@+id/contact_cell_companyName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/titleText"
            android:ellipsize="end"
            android:text="Company Name"

            android:textSize="14sp"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>
    <ImageView
        android:id="@+id/contact_cell_imageView"    
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:gravity="center_vertical"
        android:src="@drawable/ic_launcher"
        android:scaleType="centerInside"
        android:focusable="false"
         />
</LinearLayout>
<View
    android:id="@+id/contact_cell_divider" 
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:background="#e7e7e7"
    />

</LinearLayout>
  • wo ist dein Popup-Codierung, in dem Sie hinzufügen Ihre listview ? Ich habe die Ausgabe im ListView Hinzufügen im Popup
InformationsquelleAutor Scott | 2012-07-13
Schreibe einen Kommentar