Android Market-Frame Building 5

Source: Internet
Author: User

In the previous article, we have built the framework almost, leaving only the last functional framework needed, that is, the right slider bar. For the use of the right slider, we use the hot slidingmenu on GitHub to create the skid bar we need.

First we need to create a layout file for our skid bar, create a activity_left_layout.xml file under the Res/layout folder, and select the Relativelayout layout.

There are definitely some options in our slide-out bar, so we're going to use the ListView to lay out, and here's a look at the code:

    <?xml version= "1.0" encoding= "Utf-8"?>    <relativelayout xmlns:android="Http://schemas.android.com/apk/res/android" android:layout_width="Match_parent"android:layout_height="Match_parent" android:background="@color/mgrey" >                                <relativelayoutandroid:id="@+id/rl_left_main"android:layout_ Width="Match_parent"android:layout_height="Match_parent" >                                                <ListViewandroid:id="@+id/lv_test"android:layout_width="Match_ Parent "android:layout_height=" Match_parent " >                                                            </ListView>        </relativelayout>    </relativelayout>

The way the slide bar is used is very simple, now we consider to put the skid bar in the Markettab or in our homeactivity? In order to be able to use the slide bar in the global, we put him in the markettab.

Before using the slide-slip bar, we'll define several styles for the slide bar.

First create two dimen in the Dimens.xml file below our Res/values folder to see the code:

    <dimen name="shadow_width">10dp</dimen>    <dimen name="slidingmenu_offset">90dp</dimen>

These two are used to set the width and offset the width of the screen.

We also need to create a shadow.xml under the Res/drawable folder to set the background of the Slidingmenu.

We set his background to a gradient.

This is relatively simple, the source code is as follows:

    <?xml version="1.0" encoding="utf-8"?>    <shape xmlns:android="http://schemas.android.com/apk/res/android" >        <gradient            android:endColor="#33000000"            android:centerColor="#11000000"            android:startColor="#00000000" />    </shape>

Well, after defining these things, we're ready to use our slidinigmenu.

At the end of the OnCreate () method in the Markettab class we defined earlier, we added
The following code:

Slidingmenu Slidingmenu = new Slidingmenu (this);Slidingmenu. SetMode(Slidingmenu. Left);//Set Slidingmenu from the leftSlidingmenu. Settouchmodeabove(Slidingmenu. SLIDING_content);Slidingmenu. Setshadowwidthres(R. Dimen. Shadow_width);//width of shadowSlidingmenu. Setshadowdrawable(R. drawable. Shadow);//Shadow StyleSlidingmenu. Setbehindoffsetres(R. Dimen. Slidingmenu_offset);//deviation from the width of the screenSlidingmenu. Setfadedegree(0.35F;Slidingmenu. Attachtoactivity(This, slidingmenu. Touchmode_fullscreen);Slidingmenu. SetMenu(R. Layout. Activity_left_layout); The corresponding interface layout

In this way, our slidngmenu, even if it is written, we will add content to it later.

Until now, even if our framework is set up, then we have added the content, let me first talk about the idea behind us.

    • 1: Write the interface using local test data first
    • 2: Writing program interface documentation, i.e. how to interact with the server
    • 3: Write both client and server code, get data from server and layout interface

When we finally finished, we finished the project.

Come on, Comrades!!!

Copyright NOTICE: Hello, reprint please leave my blog address, thank you

Android Market-Frame Building 5

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.