@XQF
2016-07-29T22:53:21.000000Z
字数 1561
阅读 1031
匿名
消息列表界面就打开后看到的内容,当然在token进入以后我们需要判断,现在没有token我们就简单的测试
布局文件呈现消息时肯定需要一个ListView,但是每一条内容又对应一定的活动,因此我们这里使用ListActivity
package com.example.secret1.atys;
import android.app.ListActivity;
import android.os.Bundle;
import com.example.secret1.R;
public class AtyTimeline extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.aty_timeline);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list" 这里很重要
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
简单测试,将MainActivity.java进行修改
package com.example.secret1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.example.secret1.atys.AtyLogin;
import com.example.secret1.atys.AtyTimeline;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String token = Config.getCachedToken(this);// 拿到token
startActivity(new Intent(this, AtyTimeline.class));
// if (token != null) {
// // 跳转到呈现所有消息的界面
// Intent i = new Intent(this, AtyTimeline.class);
// i.putExtra(Config.KEY_TOKEN, token);// 启动之前塞几个数据,把token传过去
// startActivity(i);// 开始跳转
// } else {// 启动登陆界面
// Intent i = new Intent(this, AtyLogin.class);
// startActivity(i);
// }
finish();
}
}
重新启动模拟器发现打开的界面是白色空白的,正是我们想要的结果