模拟新浪微博界面
来源:互联网 发布:软件开发职业方向 编辑:程序博客网 时间:2024/05/17 03:24
Android之新浪微博模拟界面
public class MainActivity extends ListActivity {
private List<Map<String,?>>data;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getData();
SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.item,
new String[] { "name", "time", "word", "image" }, new int[] {
R.id.name, R.id.time, R.id.word, R.id.image });
this.setListAdapter(adapter);
}
布局文件:
1.在 layout里面建item.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/image"
android:padding="10dp"
android:layout_width="48dp"
android:layout_height="48dp"
/>
1.在 layout里面建item.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/image"
android:padding="10dp"
android:layout_width="48dp"
android:layout_height="48dp"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/name"
android:paddingTop="10dp"
android:textSize="17sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<TextView
android:id="@+id/time"
android:paddingTop="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="right"
/>
</LinearLayout>
<TextView
android:id="@+id/word"
android:paddingTop="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
</LinearLayout>
2、MianActivty文件
package cn.wh.listview2;
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/name"
android:paddingTop="10dp"
android:textSize="17sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<TextView
android:id="@+id/time"
android:paddingTop="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="right"
/>
</LinearLayout>
<TextView
android:id="@+id/word"
android:paddingTop="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</LinearLayout>
</LinearLayout>
2、MianActivty文件
package cn.wh.listview2;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.view.Menu;
import android.widget.SimpleAdapter;
import android.app.Activity;
import android.app.ListActivity;
import android.view.Menu;
import android.widget.SimpleAdapter;
public class MainActivity extends ListActivity {
private List<Map<String,?>>data;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getData();
SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.item,
new String[] { "name", "time", "word", "image" }, new int[] {
R.id.name, R.id.time, R.id.word, R.id.image });
this.setListAdapter(adapter);
}
private void getData() {
data=new ArrayList<Map<String,?>>();
Map<String,Object>item1=new HashMap<String, Object>();
item1.put("name","花溪草");
item1.put("time","2分钟前");
item1.put("word","春暖花开,终于可以出去玩啦!!");
item1.put("image",R.drawable.d);
data.add(item1);
Map<String,Object>item2=new HashMap<String, Object>();
item2.put("name","相约");
item2.put("time","25分钟前");
item2.put("word","最近太忙了!");
item2.put("image",R.drawable.a);
data.add(item2);
Map<String,Object>item3=new HashMap<String, Object>();
item3.put("name","紫玲珑");
item3.put("time","1小时前");
item3.put("word","今天好高兴啊!嘻嘻嘻");
item3.put("image",R.drawable.b);
data.add(item3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
data=new ArrayList<Map<String,?>>();
Map<String,Object>item1=new HashMap<String, Object>();
item1.put("name","花溪草");
item1.put("time","2分钟前");
item1.put("word","春暖花开,终于可以出去玩啦!!");
item1.put("image",R.drawable.d);
data.add(item1);
Map<String,Object>item2=new HashMap<String, Object>();
item2.put("name","相约");
item2.put("time","25分钟前");
item2.put("word","最近太忙了!");
item2.put("image",R.drawable.a);
data.add(item2);
Map<String,Object>item3=new HashMap<String, Object>();
item3.put("name","紫玲珑");
item3.put("time","1小时前");
item3.put("word","今天好高兴啊!嘻嘻嘻");
item3.put("image",R.drawable.b);
data.add(item3);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
3.如果想自定义标题,在values中建title.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="TitleBackground">
<item name="android:background">#FF0011</item>
</style>
<style name="selfdefine" parent="android:Theme.Light"> //注释:Theme默认为黑色
3.如果想自定义标题,在values中建title.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="TitleBackground">
<item name="android:background">#FF0011</item>
</style>
<style name="selfdefine" parent="android:Theme.Light"> //注释:Theme默认为黑色
<item name="android:windowTitleSize">30dp</item>
<item name="android:windowTitleBackgroundStyle">@style/TitleBackground</item>
</style>
</resources>
4、然后在AndroidManifest.xml文件中修改
4、然后在AndroidManifest.xml文件中修改
<activity
android:name="cn.wh.listview2.MainActivity"
android:label="@string/app_name"
android:theme="@style/selfdefine" > //
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
最终效果:
- 模拟新浪微博界面
- ListView组件的应用(模拟新浪微博界面)
- ListView应用之模拟新浪微博界面
- 模拟新浪微博随便看看界面布局
- **********模拟新浪微博*********
- 模拟新浪微博
- 模拟新浪微博
- 模拟新浪微博登陆
- 模拟新浪微博页面
- 模拟新浪微博look
- 模拟登录新浪微博
- 模拟登陆新浪微博
- 新浪微博数据采集界面
- 模拟新浪微博首页滚动效果
- httpClient4模拟登录新浪微博
- 新浪微博模拟登陆的加密算法
- 模拟登录新浪微博(Python)
- 模拟新浪微博自动登陆
- 冒泡排序及其改进算法
- <SSH>——复习之路之struts<1>
- linux指令--查询磁盘空间大小
- 关于stl vector和deque的实现对比分析
- JQuery插件实现图片拖拽删除
- 模拟新浪微博界面
- adb server is out of date. killing...
- jgit diff(比较两个版本)
- Ubuntu12.04下eclipse提示框黑色背景色的修改方法
- 云存储——够快网盘
- 输入一个数,求它之内的完数
- 性能测试的重要意义
- [Git]学习笔记 --简单远端操作命令
- hdu 1999