1

我开发了一个带有底部标签栏的 android 应用程序 gridview。

在这里,我编写了如下代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/Layout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
    <TextView
    android:id="@+id/status"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

    android:text="Mercuryminds Shoppingcart Application"

    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#040404"
    android:gravity="center" />

<GridView
    android:layout_height="0dp"
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:numColumns="auto_fit"
    android:layout_weight="1"

    android:horizontalSpacing="10dp"
    android:verticalSpacing="10dp">
</GridView>

     <include        
 android:id="@+id/footer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/footer" />


     </LinearLayout>

footer.xml 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffffff"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:layout_width="fill_parent"
    android:id="@+id/linearLayout1"
    android:background="#ffffffff"

     android:layout_height="fill_parent"
    android:orientation="vertical">
 <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1"
        android:textColor="#465371"
        android:gravity="center"
        android:textSize="13sp"

        android:textStyle="bold">
    </TextView>
    <TabWidget
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@android:id/tabs"
        android:tabStripEnabled="false"
        android:textColor="@drawable/tab_text_selector"
        android:background="@drawable/tabicon" >
    </TabWidget>

    <FrameLayout
         android:background="#ffffffff"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@android:id/tabcontent">
    </FrameLayout>
</LinearLayout>
</TabHost>

这是我的主要活动 android 代码(仅 Gridview):

    public class MainActivity extends Activity {
    static final String URL = "http://xxxxx";

         static String KEY_CATEGORY = "category";

          static final String KEY_TITLE = "categoryName";
         static final String KEY_THUMB_URL = "categoryImage";
         static final String KEY_SUBCATE = "categoryId";
 GridView lview3;
 LazyAdapter adapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
    XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml); // getting DOM element

        NodeList nl = doc.getElementsByTagName(KEY_CATEGORY);


        // looping through all song nodes &lt;song&gt;
        for (int i = 0; i < nl.getLength(); i++) {
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>   ();
            Element e = (Element) nl.item(i);
            map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
            map.put(KEY_SUBCATE, parser.getValue(e, KEY_SUBCATE));
            map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));
            songsList.add(map);
        }
    lview3 = (GridView) findViewById(R.id.gridView1);
    adapter = new LazyAdapter(this, songsList);
    lview3.setAdapter(adapter);

    lview3.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            HashMap<String, String> map = songsList.get(position);
            Intent in = new Intent(
                    MainActivity.this,
                    com.ssmobileproductions.catalogue.SubCate.class);
            in.putExtra(KEY_TITLE, map.get(KEY_TITLE));
            in.putExtra(KEY_SUBCATE, map.get(KEY_SUBCATE));

            startActivity(in);
        }  

     });

    }

      }

我如何在这些应用程序中使用标签栏开发 gridview。请给我解决方案。

我怎样才能显示像这些图像。

样本布局

4

0 回答 0