Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding Button end to GridView dynamically
    text
    copied!<p>Trying To Achieve</p> <ul> <li>Add Button After GridView which has <code>layout_height="wrap_parent"</code> &amp; <code>layout_width="fill_parent"</code> to provide better UIx.</li> </ul> <p>Constraints:</p> <ul> <li><p>Adding ImageViews which fetched from Facebook-Graph-Api to GridView which consists of ImageView.</p></li> <li><p>Add Button atlast of GridView once the Image's fetched.</p></li> </ul> <p>Tried</p> <ul> <li><p><strong>1</strong>. Setting Visibility of Button to Visible at onPostExecute() of AysncTask which helps me to fetched the Image's</p></li> <li><p><strong>2</strong>. Setting Visibility of Button to Visible at ScrollListener which would run if it Scrolling reaches end of GridView i.e <em>Last Image inside GridView</em></p></li> <li><p>But Button is not showing at the end of GridView. Dunno Why??</p></li> </ul> <p>My XML Layout::</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:id="@+id/rootview" &gt; &lt;Button android:id="@+id/fbconnect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/connectfb" android:layout_centerHorizontal="true" android:visibility="visible" /&gt; &lt;GridView android:id="@+id/gridphoto" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:columnWidth="80dp" android:numColumns="auto_fit" android:verticalSpacing="2dp" android:horizontalSpacing="2dp" android:stretchMode="columnWidth" /&gt; &lt;Button android:id="@+id/loadmore" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_below="@id/gridphoto" android:visibility="gone" android:text="@string/load_more" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Code :: Fetching Images via AysncTask and Setting Visibility at onPostExecute to add LoadMore Button at end of GridView.</p> <pre><code> protected void onPostExecute(Void result) { loadMore.setVisibility(View.VISIBLE); // Load More Button } </code></pre> <p>Code :: Implementing ScrollListener on GridView -- > Checking If it reaches bottom or not then changing Visibility of Load More button.</p> <pre><code>public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (gridView.getLastVisiblePosition() + 1 == increasingItem) // Checking if it reaches bottom of GridView or not. It prefectly runs. Checked via Logging into StackTrace. { loadMore.setVisibility(View.VISIBLE); // Load More Button } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload