J'ai une boîte de dialogue pour choisir les fichiers. Cette boîte de dialogue contient un listview pour afficher les répertoires et les fichiers et dispose d'un onItemClickListener à des fins de navigation.Android onTouchListener pour le dialogue entier
Comment puis-je réagir à des événements de lancement dans la structure de répertoires? J'ai essayé une mise OnTouchListener sur le RelativeLayout racine pour toucher les événements à mon GestureListener dépêches:
final GestureDetector detector = new GestureDetector(new MyGestureDetector(tvCurrentPath));
dialog.findViewById(R.id.rlFilelist).setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View view, MotionEvent e) {
detector.onTouchEvent(e);
return false;
}
});
Les événements s'enregistrés dans OnTouch(), mais la méthode onFling() est jamais appelé dans le MyGestureDetector. Si, cependant, j'attache le OnTouchListener à la listview, cela fonctionne comme prévu. Le problème avec cette approche est que la liste n'est pas toujours remplie avec des données et quand elle est vide ou lorsque vous cliquez sur les éléments ci-dessous, aucun événement onTouch() n'est déclenché.
mise en page de dialogue:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rlFilelist"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/llButtons" >
<TextView
android:id="@+id/tvCurrentPath"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip" >
</TextView>
<ListView
android:id="@+id/lvFileListing"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/llButtons"
android:layout_below="@id/tvCurrentPath" >
</ListView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/llButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dip"
android:layout_marginTop="5dip" >
<Button
android:id="@+id/btAddDirectory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="10px"
android:text="@string/host_tv_dg_add_directory" />
<Button
android:id="@+id/btUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10px"
android:layout_toRightOf="@id/btAddDirectory"
android:text="@string/host_tv_dg_navigate_up" />
<Button
android:id="@+id/btClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/btUp"
android:text="@string/_tv_close" />
</RelativeLayout>
</RelativeLayout>
Capture d'écran pour le dialogue avec pas complètement rempli lisview: http://imageshack.us/photo/my-images/802/dialog.png/
Comment puis-je faire les événements onFling() déclenchent la boîte de dialogue tout ou sur le « tout » listview même quand il n'est pas complètement rempli d'objets?
Merci!