Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid-How to add grid view in footer of list view in
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/s6Lbk.png" alt="enter image description here"></p> <p>I have one grid view which i want to add in footer of listview because i want this page should have full page scrolling functionality.</p> <p>here is my code where i am setting my grid view with my grid view adapter but its showing blank in footer.i have two xml one is for header and other one is only for grid view.</p> <p>GalleryGridViewAdapter</p> <pre><code>public class GalleryMainActivityGridViewAdapter extends BaseAdapter { /** * Description:Declare the UI components. */ private Context mContextGridView; private GallerySmartLazyLoader sl; ArrayList&lt;HashMap&lt;String, String&gt;&gt; galleryArray; /** * This method is use to set object that will control the listview * * @param c * @param resultArray * */ public GalleryMainActivityGridViewAdapter(Context c, ArrayList&lt;HashMap&lt;String,String&gt;&gt; resultArray) { mContextGridView = c; galleryArray = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); galleryArray = resultArray; sl = new GallerySmartLazyLoader(mContextGridView); } public int getCount() { return galleryArray.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } /** * Description:This method returns a bitmap related to drawable. * * @param bitmapUrl * to set the background on detail page * */ public Bitmap getBitmap(String bitmapUrl) { URL url; try { System.out.println("bitmapUrl :" + " bitmapUrl : " + bitmapUrl); url = new URL(bitmapUrl); return BitmapFactory.decodeStream(url.openConnection().getInputStream()); } catch (Exception ex) { ex.printStackTrace(); } return null; } // create View for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { View MyView = convertView; if (convertView == null) { /* create a new view of our layout and inflate it in the row */ // Inflate the layout LayoutInflater inflater = (LayoutInflater) mContextGridView.getSystemService(Context.LAYOUT_INFLATER_SERVICE); MyView = inflater.inflate(R.layout.gallery_main_page_grid_item, null); // Initialize the UI components ImageView imgView_Grid_PlayVideo = (ImageView) MyView.findViewById(R.id.imgView_Grid_PlayVideo); ImageView imgView_Grid_Thumbnail_Gallery = (ImageView) MyView.findViewById(R.id.imgView_Grid_Thumbnail_Gallery); TextView txtView_Grid_Views_Gallery = (TextView) MyView.findViewById(R.id.txtView_Grid_Views_Gallery); Typeface txtViewForViews = Typeface.createFromAsset(MyView.getContext().getAssets(), "fonts/arial.ttf"); txtView_Grid_Views_Gallery.setTypeface(txtViewForViews); TextView txtView_Grid_Name_Gallery = (TextView) MyView.findViewById(R.id.txtView_Grid_Name_Gallery); Typeface txtViewForName = Typeface.createFromAsset(MyView.getContext().getAssets(), "fonts/arial_bold.ttf"); txtView_Grid_Views_Gallery.setTypeface(txtViewForName); ImageView imgView_GridItem_Gallery = (ImageView) MyView.findViewById(R.id.imgView_GridItem_Gallery); // This will set the item coming from API imgView_Grid_Thumbnail_Gallery.setImageBitmap(getBitmap(galleryArray.get(0).get("publicUrl") + "/11")); txtView_Grid_Views_Gallery.setText(galleryArray.get(position).get("hits") + " views"); txtView_Grid_Name_Gallery.setText(galleryArray.get(position).get("user_name")); imgView_GridItem_Gallery.setScaleType(ImageView.ScaleType.FIT_XY); imgView_GridItem_Gallery.setPadding(0, 0, 0, 0); String url = galleryArray.get(position).get("thumbUrl") + "/13"; imgView_GridItem_Gallery.setTag(url); sl.DisplayImage(url, (Activity) mContextGridView, imgView_GridItem_Gallery); if (galleryArray.get(position).get("filetype").toString().equals("1")) { imgView_Grid_PlayVideo.setVisibility(View.GONE); } else { imgView_Grid_PlayVideo.setVisibility(View.VISIBLE); } } return MyView; } } </code></pre> <p>GallaryLoginMainActivity</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallary_login_main_page_list); data = new ArrayList&lt;ArrayList&lt;HashMap&lt;String, String&gt;&gt;&gt;(); lstGallaryMain = (ListView) findViewById(R.id.lstGallaryMain); inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); init(this, R.id.main, getIntent()); if (!Connection()) { Context context = getApplicationContext(); CharSequence text = "Sorry you need an Internet connection! Please try again when the network is available."; Toast toast = Toast.makeText(context, text, Toast.LENGTH_LONG); toast.show(); finish(); } else { /* * * This method is used to Show The loading dialog till the data * loads for main page. */ new AsyncTask&lt;Void, Void, Void&gt;() { protected void onPreExecute() { loadingDialog = ProgressDialog.show(GallaryLoginMainActivity.this, getResources().getString(R.string.app_name), "Loading..."); } @Override protected Void doInBackground(Void... params) { loadDataFromServer(); return null; }; protected void onPostExecute(Void result) { View footerView = inflater.inflate(R.layout.test_media, null); GalleryMainActivityGridViewAdapter galleryMainActivityGridViewAdapter = new GalleryMainActivityGridViewAdapter(GallaryLoginMainActivity.this,userDataActivity); GridView gridView = (GridView)footerView.findViewById(R.id.gridview_Gallery); gridView.setAdapter(galleryMainActivityGridViewAdapter); lstGallaryMain.addFooterView(gridView); ((GalleryMainActivityGridViewAdapter)(galleryMainActivityGridViewAdapter)).notifyDataSetChanged(); lstGallaryMain.setAdapter(new GalleryCustomAdapterForMainPage&lt;T&gt;(GallaryLoginMainActivity.this, data)); ((BaseAdapter)(lstGallaryMain.getAdapter())).notifyDataSetChanged(); lstGallaryMain.addFooterView(gridView); GallaryLoginMainActivity.this.onContentChanged(); if (loadingDialog != null &amp;&amp; loadingDialog.isShowing()) { loadingDialog.dismiss(); } }; }.execute(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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