Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1)create an xml layout for gridview.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/GridView01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:numColumns="auto_fit" android:columnWidth="80dp" android:stretchMode="columnWidth" android:gravity="center" android:background="@color/white" &gt; &lt;/GridView&gt; </code></pre> <p>2) create one more layout home_screen_text.xml</p> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget44" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_x="201px" android:layout_y="165px" android:gravity="center_horizontal" &gt; &lt;ImageView android:id="@+id/icon_image" android:layout_width="wrap_content" android:layout_height="80dp" &gt; &lt;/ImageView&gt; &lt;TextView android:id="@+id/icon_text" android:typeface="serif" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:textColor="@color/black" android:textStyle="bold" android:lines="2"&gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>3) then use a gridView. GridView gridview = (GridView) findViewById(R.id.GridView01); gridview.setAdapter(new ImageAdapter(this)); gridview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { } }</p> <p>4) create a imageadapter class that inherits baseadapter.</p> <pre><code> public class ImageAdapter extends BaseAdapter { private Context mContext; public static final int ACTIVITY_CREATE = 10; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds1.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; View v; if (convertView == null) { imageView = new ImageView(mContext); LayoutInflater li = getLayoutInflater(); v = li.inflate(R.layout.home_screen_text, null); TextView tv = (TextView) v.findViewById(R.id.icon_text); tv.setText("" + iconText.get(position).toString()); ImageView iv = (ImageView) v.findViewById(R.id.icon_image); iv.setImageResource(mThumbIds1.get(position)); } else { v = convertView; imageView = new ImageView(mContext); LayoutInflater li = getLayoutInflater(); v = li.inflate(R.layout.home_screen_text, null); TextView tv = (TextView) v.findViewById(R.id.icon_text); tv.setText("" + iconText.get(position).toString()); ImageView iv = (ImageView) v.findViewById(R.id.icon_image); iv.setImageDrawble(drawable_from_url("url of the image", "name")); } return v; } } </code></pre> <p>The method that returns drawable. Drawable drawable_from_url(String url, String src_name) throws java.net.MalformedURLException, java.io.IOException { return Drawable.createFromStream(((java.io.InputStream)new java.net.URL(url).awagetContent()), src_name); }</p>
    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.
    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