Android Market-framework building 5, Android-framework building
In the previous article, we have set up the framework almost. the last required functional framework is the right slide bar. For the use of the right slide bar, we use the hot SlidingMenu on github to create the slide bar we need.
First, we need to create a layout file for our slide bar, create an activity_left_layout.xml file under the res/layout folder, and select the RelativeLayout layout.
Some options must be put in our slide bar, so we use ListView for layout. Let's take a look at the code below:
<?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" > <RelativeLayout android:id="@+id/rl_left_main" android:layout_width="match_parent" android:layout_height="match_parent" > <ListView android:id="@+id/lv_test" android:layout_width="match_parent" android:layout_height="match_parent" > </ListView> </RelativeLayout> </RelativeLayout>
The usage of the slide bar is very simple. Now we want to put the slide bar in the MarketTab or in our HomeActivity? To make the slide bar available globally, we put it in the MarketTab.
Before using the slide bar, we first define several styles for the slide bar.
First, create two dimen In The dimens. xml file under our res/values folder and check the Code:
<dimen name="shadow_width">10dp</dimen> <dimen name="slidingmenu_offset">90dp</dimen>
The two are used to set the width and the width of the screen deviation respectively.
We also need to create a shadow. xml file under the res/drawable folder to set the background of the SlidingMenu.
We set the background to gradient.
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>
Now, after defining these things, we can use our SlidinigMenu.
At the end of the onCreate () method in the MarketTab class we previously defined, we add
The following code:
SlidingMenu slidingMenu = new SlidingMenu (this); slidingMenu. setMode (SlidingMenu. LEFT); // set SlidingMenu to draw slidingMenu from the LEFT. setTouchModeAbove (sregistringmenu. SLIDING_CONTENT); slidingMenu. setShadowWidthRes (R. dimen. shadow_width); // The width of the shadow slidingMenu. setShadowDrawable (R. drawable. shadow); // shadow style slidingMenu. setBehindOffsetRes (R. dimen. slidingmenu_offset); // The slidingMenu that deviates from the screen width. setFadeDegree (0.35f); slidingMenu. attachToActivity (this, SlidingMenu. TOUCHMODE_FULLSCREEN); slidingMenu. setMenu (R. layout. activity_left_layout); // corresponding interface Layout
In this way, even if the SlidngMenu is well written, we will add content to it later.
Till now, even if our framework has been set up, we have added content later. Let's talk about our ideas later.
- 1: first use the local Test Data Writing Interface
- 2: Compile the program interface document, that is, how to interact with the server
- 3: Write the client and server code at the same time, get data from the server and layout the interface
After that, we have finished the project.
Come on, comrades !!!
Copyright Disclaimer: Hello, please leave the address of your blog for reprinting. Thank you.