Sina Weibo open platform development-android client (3)

Source: Internet
Author: User
Tags oauth

 

Introduction

I am not too busy recently. I spent some time learning about android application development. After two weeks of study, I also wrote a lot of demo examples, which can be pushed to the demo set of basic controls and basic animation effects for continuous update and download.

Starting from this week, we are going to take the Sina Weibo open platform as an example to develop an android client with simple functions, which will improve functions as much as possible.

Today's content

 

Is the main interface of this client. Features added today.

 

Simple Style and skin, just adding a button.

The running system is android2.2.

The technical points used include ListView, custom ListAdapter, Message related to multithreading, Handler, OAuth related to verification, and asynchronous loading of user images.

 

Sina Weibo uses the OAuth component of signpost and does not use the Weibo SDK.

 

 

Download source code:

 

SinaWeibo2

 

After downloading the source code, change the suffix to rar and decompress it with the compression software.

Style and Themey Style and skin

Through styles and skins, We can beautify our UI. After beautifying the UI, we will attract more users. At least we will not make our apps look ugly (of course, we also need reasonable styles and skins, otherwise it may be more ugly ).

 

Style and skin can be used in the following scenarios:

 

1. Add an independent style to a widget

 

Define a style view sourceprint? 1 <style name = "Text">

 

2 <item name = "android: textSize"> 20sp </item>

 

3 <item name = "android: textColor"> # 00dd9a </item>

 

4 </style>

 

Then use the set style view sourceprint in the control of the layout file? 1 <TextView android: text = "Sina Weibo V2" style = "@ style/Text"

 

2 android: layout_width = "wrap_content" android: layout_height = "wrap_content"/>

 

2. Add the same style to several controls

 

Define a style view sourceprint? 1 <style name = "Text">

 

2 <item name = "android: textSize"> 20sp </item>

 

3 <item name = "android: textColor"> # 00dd9a </item>

 

4 </style>

 

How many controls are used to set the view sourceprint style? 1 <TextView android: text = "Sina Weibo V2" style = "@ style/Text"

 

2 android: layout_width = "wrap_content" android: layout_height = "wrap_content"/>

 

3 <TextView android: text = "Welcome to" style = "@ style/Text"

 

4 android: layout_width = "wrap_content" android: layout_height = "wrap_content"/>

 

3. There are two ways to modify the style of controls of the same type, such as the style of all buttons.

 

Method 1: Define a style and apply the style to the style attribute in each button. View sourceprint? 01 <style name = "Button" parent = "@ android: style/Widget. Button">

 

02 <item name = "android: gravity"> center_vertical | center_horizontal </item>

 

03 <item name = "android: textColor"> # FFFFFFFF </item>

 

04 <item name = "android: shadowColor"> # FF000000 </item>

 

05 <item name = "android: shadowDx"> 0 </item>

 

06 <item name = "android: shadowDy">-1 </item>

 

07 <item name = "android: shadowRadius"> 0.2 </item>

 

08 <item name = "android: textSize"> 16dip </item>

 

09 <item name = "android: textStyle"> bold </item>

 

10 <item name = "android: background"> @ drawable/com_sinaweibo2_list_button_selector </item>

 

11

 

12

 

13

 

14 </style>

View sourceprint? 1 <Button android: text = "Add" android: id = "@ + id/com_sinaweibo2_list_btnAdd"

 

2 style = "@ style/Button"

 

3 android: layout_toRightOf = "@ id/com_sinaweibo2_list_btnRefresh"

 

4 android: layout_height = "wrap_content" android: layout_width = "wrap_content"/>

 

Method 2: defined as skin, and then applied to application or activity in the manifest file. View sourceprint? 01 <style name = "Button" parent = "@ android: style/Widget. Button">

 

02 <item name = "android: gravity"> center_vertical | center_horizontal </item>

 

03 <item name = "android: textColor"> # FFFFFFFF </item>

 

04 <item name = "android: shadowColor"> # FF000000 </item>

 

05 <item name = "android: shadowDx"> 0 </item>

 

06 <item name = "android: shadowDy">-1 </item>

 

07 <item name = "android: shadowRadius"> 0.2 </item>

 

08 <item name = "android: textSize"> 16dip </item>

 

09 <item name = "android: textStyle"> bold </item>

 

10 <item name = "android: background"> @ drawable/com_sinaweibo2_list_button_selector </item>

 

11

 

12

 

13

 

14 </style>

 

15 <style name = "CustomButton" parent = "@ android: style/Theme. NoTitleBar">

 

16 <item name = "android: buttonStyle"> @ style/Button </item>

 

17 </style>

View sourceprint? 1 <application android: icon = "@ drawable/icon" android: label = "@ string/app_name"

 

2 android: theme = "@ style/CustomButton">

 

Obviously, the second advantage is to modify the style, or even the style name. You only need to modify the style definition. You do not need to modify the style anywhere. In the second method, the application scope of the style is an activity or the entire application. If you want to control several buttons, you can only use the first method.

 

Notes

 

For text purposes, define a style.

 

If you want to use the control, you need to inherit a style of the base class and modify it yourself. Otherwise, the control will only have the style you defined, and none of the others will be available, you can even click a button because the style definition is incomplete. To ensure the definition is complete, you need to inherit the control style of the system and then make your own modifications.

 

The buttonStyle in <item name = "android: buttonStyle"> @ style/Button </item> indicates that the style or skin is applied to all buttons. Each control has these styles, such as listViewStyle and textViewStyle. You can search in the skin that comes with the system. In addition, style and skin usage and built-in style are good learning resources.

More functions

The following functions may be supported:

 

Context menu, delete, add follow, cancel follow, view a user's Weibo, and so on.

Post a blog post to support images.

UI beautification and performance optimization.

Summary

They are all good entry books. I have not read all the books. After reading most of the books, I will write a demo while reading them.

 

At the same time, every day at the Forum http://www.eoeandroid.com/forum.php, eoedeveloper portal. Answer questions, solve problems, raise questions, and post posts. In short, it means training yourself and forcing yourself to exercise the foundation and thinking.

 

There are many Chinese pdf tutorials on the Forum, but most of them are translated into the Dev Guide and Resources of the android developer center. Therefore, if the English language is not very poor, it is recommended to read the two sections above and practice the examples at the same time to ensure that you will make great progress in two weeks.

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.