How to throw blank activity by pressing the SearchView button?

0

I'm following this tutorial to create a SearchView in android studio with php and mysql all works well the only problem is that the results of the search are shown in a Recyclerview that is in the main layout of the app or the activity_main where I already have other things for my app, I would like to know how you could show the results in a layout blank at the time of doing the search without having to leave the main activity, I hope your advice thanks.

    
asked by Cosme Fulanito 09.09.2017 в 17:15
source

2 answers

0

Occupy split the friend screen

Here you would define "weights" with the layout_weight property in your view, assuming the following example, in which we need that our bottom view always occupies 50% of the screen and is positioned at the bottom, but we also need add another 2 views, one occupying 30% of the screen and the second 20%.

If we take into account the total of the screen as 1, we assign a value of .50 so that it always occupies 50% of the screen our view:

   <WebView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".50"
        android:id="@+id/webView"
        android:layout_alignParentBottom="true" />

and so with the other views, one will occupy 30% (we assign .30) and the other 20% (we assign .20):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".30"
        android:text="Vista 1" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".20"
        android:text="Vista 2" />

    <WebView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight=".50"
        android:id="@+id/webView"
        android:layout_alignParentBottom="true" />


</LinearLayout>

We can ensure that the views will have the percentage specified on the screen and you decide where to get the result.

I hope my palomita friend: D

    
answered by 09.09.2017 в 18:45
0

In the main layout you create 2 layouts and in the one that is at the bottom you add the recyclerView:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<RelativeLayout
    android:id="@+id/layout_01"
    android:layout_width="match_parent"
    android:layout_height="200dp">

    <TextView
        android:id="@+id/textView1"
        android:text="Layout Superior"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginLeft="116dp"
        android:layout_marginStart="116dp"
        android:layout_marginTop="17dp" />
</RelativeLayout>


<RelativeLayout
    android:id="@+id/layout_02"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_below="@+id/layout_01">

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="142dp"
    android:layout_marginStart="142dp"
    android:layout_marginTop="24dp"
    android:text="Resultados" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/textView2"
    android:scrollbars="vertical"/>
</RelativeLayout>

In this case the size ( android:layout_height="200dp" ) is 200 dp, but it may be the one you want or if you want them to occupy half of the screen add android:layout_weight=".5"

    
answered by 09.09.2017 в 21:21