Création d'un Drawer personnalisé
Bonjour
J'aimerai ajouter à mon application un drawer dans lequel on trouverait un EditText qui me permetterait de faire une recherche filtrée sur la gridView d'image qui constitue mon application.
Pour le moment j'aimerai juste que mon drawer + sont EditText soit visible à l'écran. Car en effet actuellement j'ai l'impression que le drawer est pris en compte mais ne s'affiche pas. Je m'explique lorsque je slide avec mon doigt de gauche à droite, l'écran s'assombrit comme si le drawer apparaissait, je n'ai plus d'intéraction possible avec ma gridView, mais rien ne s'affiche, l'écran est juste plus sombre. Lorsque je retouche une fois l'écran, il redevient claire je peu alors interagir avec ma gridView, comme si le drawer était parti.
Voici mon code :
* activity_girdView.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| <android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<LinearLayout
android:id="@+id/linearlayout"
android:layout_height="wrap_content"
android:layout_width="240dp"
android:orientation="vertical"
android:layout_gravity="start" >
<EditText
android:id="@+id/EditText01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search" >
</EditText>
<ListView android:id="@+id/left_drawer_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</LinearLayout>
<!-- The GridView to display picture s preview -->
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:gravity="center"
android:stretchMode="columnWidth"
android:background="#000000">
</GridView>
</android.support.v4.widget.DrawerLayout> |
* GridViewActivity.java (une partie) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
public class GridViewActivity extends Activity {
static final String url = "http:/url/service_json.php";
private GridViewImageAdapter adapter;
private GridView gridView;
private DrawerLayout drawerLayout;
private ListView drawerList;
private LinearLayout linearLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gridview);
final JsonDownloaderTask task = new JsonDownloaderTask(this);
task.execute(url);
gridView = (GridView) findViewById(R.id.grid_view);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerList = (ListView) findViewById(R.id.left_drawer_list);
linearLayout = (LinearLayout) findViewById(R.id.linearlayout);
// L'adapter pour ma gridView est initialisé à la fin de mon opération
// asynchrone (grâce à ma classe JsonDowloaderTask)
// tout fonctionne très bien sauf l'affichage de mon drawer.
} |
Merci d'avance pour tout aide que vous pourrez me fournir.