新浪微博开发(四)微博客户端第一个界面

在前面几讲中,我向大家介绍了微博开发的基础知识,下面正式开始编码开发。首先建立一个工程,这里我取名叫Sina,见下图:

修改工程的图标,在manifest文件里面修改,把默认图标改成如下:

接着在SinaActivity.java文件中进行欢迎界面的编写和处理。效果图:


将要使用到的按钮的图标:

将用到的背景图:

这是一个注重版权的时代,网络崇尚分享的同时,更崇尚真实,所以我要强调一下,上面用到的背景图是梵高的油画,点击查看:源地址

/* * 这个类是整个工程的入口类,在manifest里IntentFilter标签中做了声明 * 因而启动工程后,该类首先被执行 * 它负责显示欢迎界面,界面的下方有三个按钮,左边的是登录按钮,中间的是管理按钮,左边的是退出按钮 * 用户点击管理按钮,会跳转到另一个activity,在那里管理自己的微博账号,包括新浪微博账号,腾讯微博账号等 */ package tianyi.sina; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.Toast; public class SinaActivity extends Activity { private ImageButton addButton; private ImageButton exitButton; private ImageButton manageButton; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sinaacitivityview); addButton = (ImageButton) this .findViewById(R.id.imageButtonLoginInButton); exitButton = (ImageButton) findViewById(R.id.imageButtonExitButton); manageButton = (ImageButton) findViewById(R.id.imageButtonManageButton); addButton.setOnClickListener(new LoginButtonListener()); exitButton.setOnClickListener(new ExitButtonListener()); manageButton.setOnClickListener(new manageButtonListener()); } class manageButtonListener implements OnClickListener { @Override public void onClick(View v) { Intent intent = new Intent(); // 激活显示新浪微博、腾讯微博、土豆、人人等账户的activity intent.setClass(SinaActivity.this, AppList.class); startActivity(intent); finish(); } } /* * 当用户点击登录按钮后,程序需要进行判断 * 首先判断用户是否先前已经成功登录过,若是,直接跳转到微博界面 * 若否,跳转到AppList界面,即跳转到账户管理界面进行登录 */ class LoginButtonListener implements OnClickListener { @Override public void onClick(View v) { /** 待续~~ **/ } } class ExitButtonListener implements OnClickListener { @Override public void onClick(View v) { finish(); } } }
读完上面的代码,你肯定想知道我的AppList设计成了什么样子,见下图:


我把生成的main.xml文件删除了,另写了一个,上面的activity用的是该xml:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/welcomview_background"> <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" > <ImageButton android:id="@+id/imageButtonExitButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_marginBottom="30dp" android:layout_marginRight="16dp" android:background="@drawable/exit3" /> <ImageButton android:id="@+id/imageButtonLoginInButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/imageButtonExitButton" android:layout_alignParentLeft="true" android:layout_marginBottom="89dp" android:background="@drawable/login3" /> <ImageButton android:id="@+id/imageButtonManageButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/imageButtonExitButton" android:layout_marginBottom="14dp" android:layout_toLeftOf="@+id/imageButtonExitButton" android:background="@drawable/manage3" android:text="Mange" /> </RelativeLayout> </LinearLayout>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值