[关闭]
@XQF 2016-07-29T22:53:21.000000Z 字数 1561 阅读 1031

《匿名》第八课----消息列表界面设计

匿名


消息列表界面就打开后看到的内容,当然在token进入以后我们需要判断,现在没有token我们就简单的测试

布局文件呈现消息时肯定需要一个ListView,但是每一条内容又对应一定的活动,因此我们这里使用ListActivity

AtyTimeline.java

  1. package com.example.secret1.atys;
  2. import android.app.ListActivity;
  3. import android.os.Bundle;
  4. import com.example.secret1.R;
  5. public class AtyTimeline extends ListActivity {
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. // TODO Auto-generated method stub
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.aty_timeline);
  11. }
  12. }

aty_timeline.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical" >
  6. <ListView
  7. android:id="@android:id/list" 这里很重要
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent" >
  10. </ListView>
  11. </LinearLayout>

简单测试,将MainActivity.java进行修改

  1. package com.example.secret1;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import com.example.secret1.atys.AtyLogin;
  6. import com.example.secret1.atys.AtyTimeline;
  7. public class MainActivity extends Activity {
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. String token = Config.getCachedToken(this);// 拿到token
  12. startActivity(new Intent(this, AtyTimeline.class));
  13. // if (token != null) {
  14. // // 跳转到呈现所有消息的界面
  15. // Intent i = new Intent(this, AtyTimeline.class);
  16. // i.putExtra(Config.KEY_TOKEN, token);// 启动之前塞几个数据,把token传过去
  17. // startActivity(i);// 开始跳转
  18. // } else {// 启动登陆界面
  19. // Intent i = new Intent(this, AtyLogin.class);
  20. // startActivity(i);
  21. // }
  22. finish();
  23. }
  24. }

重新启动模拟器发现打开的界面是白色空白的,正是我们想要的结果

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注