- 浏览: 272274 次
- 性别:
- 来自: 成都
博客专栏
-
Android腾讯微博客户...
浏览量:94462
文章分类
最新评论
-
依旧如风:
u012209919 写道一按“添加用户”就出错了,
Android腾讯微薄客户端开发十五:终结篇(分享源代码) -
bn922:
wxw1111wang 写道楼主黑屏怎么解决啊?急求你看看是不 ...
利用ffmpeg和SDL实现一个跨android版本的音视频播放器 -
wxw1111wang:
楼主黑屏怎么解决啊?急求
利用ffmpeg和SDL实现一个跨android版本的音视频播放器 -
lwbao28:
为什么下载下来解压后没有后缀名,都不知道怎么打开。
利用ffmpeg和SDL实现一个跨android版本的音视频播放器 -
璇儿0227:
为什么打开后页面显示不出来,而且没法添加账户?代码也没有显示错 ...
Android腾讯微薄客户端开发十五:终结篇(分享源代码)
点击顶部的标题栏,界面跳转到此博主的关注界面
关注界面,此界面下面的对话和点评以及上面的广播,听众和收听丑了点,没时间了,今天时间比较紧,美化的事情交给你们了。
public class UserInfoActivity extends Activity implements OnItemClickListener{ private String currentNick; private String name; private String origtext; private String timestamp; private DataHelper dataHelper; private UserInfo user; private MyWeiboSync weibo; private Handler handler; private AsyncImageLoader asyncImageLoader; private UserInfoThread thread; private String weiboid; private String returnJsonStr; private JSONObject dataObj ; private ImageView user_headicon; private TextView user_nick; private TextView user_name; private TextView user_origtext; private TextView user_time; private TextView user_sex; private TextView user_age; private TextView user_location; private TextView user_verifyinfo; private Button user_back_btn; private Button user_dialog_btn; private Button user_message_btn; private GridView gridView; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.user_info); setUpViews();//设置view setUpListeners();//设置listenter asyncImageLoader = new AsyncImageLoader(); dataHelper = new DataHelper(UserInfoActivity.this); weibo = new MyWeiboSync(); List<UserInfo> userList = dataHelper.GetUserList(false); SharedPreferences preferences = getSharedPreferences("default_user",Activity.MODE_PRIVATE); String nick = preferences.getString("user_default_nick", ""); if (nick != "") { user = dataHelper.getUserByName(nick,userList); } weibo.setAccessTokenKey(user.getToken()); weibo.setAccessTokenSecrect(user.getTokenSecret()); //获取从上一界面传递过来的数据 Intent intent = getIntent(); name = intent.getStringExtra("name"); currentNick = intent.getStringExtra("nick");//昵称 origtext = intent.getStringExtra("origtext"); timestamp = intent.getStringExtra("timestamp"); user_name.setText("@"+name); user_origtext.setText(origtext); user_time.setText(timestamp); handler = new UserInfoHandler(); thread = new UserInfoThread(); thread.start();//开启一个线程获取数据 } private void setUpViews(){ user_headicon = (ImageView) findViewById(R.id.user_headicon); user_nick = (TextView) findViewById(R.id.user_nick); user_name = (TextView) findViewById(R.id.user_name); user_origtext = (TextView) findViewById(R.id.user_origtext); user_time = (TextView) findViewById(R.id.user_time); user_sex = (TextView) findViewById(R.id.user_sex); user_age = (TextView) findViewById(R.id.user_age); user_location = (TextView) findViewById(R.id.user_location); user_verifyinfo = (TextView) findViewById(R.id.user_verifyinfo); user_back_btn = (Button) findViewById(R.id.user_back_btn); user_dialog_btn = (Button) findViewById(R.id.user_dialog_btn); user_message_btn = (Button) findViewById(R.id.user_message_btn); gridView = (GridView)findViewById(R.id.user_grid); } private void setUpListeners(){ gridView.setOnItemClickListener(this); } class UserInfoThread extends Thread { @Override public void run() { returnJsonStr = weibo.getUserInfoByName(weibo.getAccessTokenKey(), weibo.getAccessTokenSecrect(), name); //通知handler处理数据 Message msg = handler.obtainMessage(); handler.sendMessage(msg); } } class UserInfoHandler extends Handler { @Override public void handleMessage(Message msg){ Drawable cachedImage; try { dataObj = new JSONObject(returnJsonStr).getJSONObject("data"); cachedImage = asyncImageLoader.loadDrawable(dataObj.getString("head")+"/100",user_headicon, new ImageCallback(){ @Override public void imageLoaded(Drawable imageDrawable,ImageView imageView, String imageUrl) { imageView.setImageDrawable(imageDrawable); } }); if (cachedImage == null) { user_headicon.setImageResource(R.drawable.icon); } else { user_headicon.setImageDrawable(cachedImage); } user_nick.setText(dataObj.getString("nick")); user_sex.setText(dataObj.getInt("sex")==1?"男":"女"); if(dataObj.getInt("birth_year")!=0){ user_age.setText((Calendar.getInstance().get(Calendar.YEAR)-dataObj.getInt("birth_year"))+"岁"); } user_location.setText(dataObj.getString("location")); String verifyinfo = dataObj.getString("verifyinfo"); if(verifyinfo==null||"".equals(verifyinfo)){ user_verifyinfo.setText("这家伙很懒,没留什么"); }else{ user_verifyinfo.setText(verifyinfo); } final List<String> numsList = new ArrayList<String>(); numsList.add(dataObj.getString("tweetnum")); numsList.add(dataObj.getString("fansnum")); numsList.add(dataObj.getString("idolnum")); gridView.setAdapter(new GridAdapter(UserInfoActivity.this, numsList)); } catch (JSONException e) { e.printStackTrace(); } } } class GridAdapter extends BaseAdapter { private Context context; private LayoutInflater inflater; List<String> numList; public GridAdapter(Context context, List<String> numList) { super(); this.context = context; this.numList = numList; this.inflater = LayoutInflater.from(context); } @Override public int getCount() { return numList.size(); } @Override public Object getItem(int position) { return numList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent){ convertView = inflater.inflate(R.layout.userinfo_grid_item, null); TextView num = (TextView)convertView.findViewById(R.id.userinfo_grid_num); TextView title = (TextView)convertView.findViewById(R.id.userinfo_grid_title); ImageView image = (ImageView)convertView.findViewById(R.id.userinfo_grid_image); switch (position) { case 0: num.setText(numList.get(0)); title.setText("广播"); image.setVisibility(View.VISIBLE); break; case 1: num.setText(numList.get(1)); title.setText("听众"); image.setVisibility(View.VISIBLE); break; case 2: num.setText(numList.get(2)); title.setText("收听"); break; default: break; } return convertView; } } @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3){ switch (position) { case 0: Intent intent = new Intent(UserInfoActivity.this,TweetsActivity.class); intent.putExtra("name", name); intent.putExtra("nick",currentNick); startActivity(intent); break; case 1: Intent intent2 = new Intent(UserInfoActivity.this,FansActivity.class); intent2.putExtra("name", name); intent2.putExtra("nick",currentNick); startActivity(intent2); break; case 2: Intent intent3 = new Intent(UserInfoActivity.this,IdolActivity.class); intent3.putExtra("name", name); intent3.putExtra("nick",currentNick); startActivity(intent3); break; default: break; } } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#c0c8d0" xmlns:android="http://schemas.android.com/apk/res/android"> <RelativeLayout android:id="@+id/user_top" android:paddingTop="5.0dip" android:layout_width="fill_parent" android:layout_height="60.0dip" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"> <ImageView android:id="@+id/user_headicon" android:layout_marginLeft="8.0dip" android:layout_width="45.0dip" android:layout_height="45.0dip" android:layout_alignParentLeft="true"/> <TextView android:id="@+id/user_nick" android:layout_marginLeft="5.0dip" android:layout_width="wrap_content" android:layout_toRightOf="@id/user_headicon" android:textColor="#384050" android:layout_height="wrap_content"/> <TextView android:id="@+id/user_name" android:layout_width="wrap_content" android:layout_marginLeft="10.0dip" android:layout_toRightOf="@id/user_headicon" android:textColor="#687888" android:layout_height="wrap_content" android:layout_below="@id/user_nick"/> </RelativeLayout> <LinearLayout android:paddingLeft="10.0dip" android:paddingRight="10.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_below="@id/user_top"> <ImageView android:background="#a0b0b0" android:layout_width="fill_parent" android:layout_height="1.0dip" android:scaleType="fitCenter"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip"> <GridView android:gravity="center" android:listSelector="@drawable/listitem_selector" android:id="@+id/user_grid" android:background="@drawable/userinfo_grid_bg" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="3"/> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:background="@drawable/panel_bg"> <TextView android:id="@+id/user_sex" android:layout_marginLeft="5.0dip" android:layout_alignParentLeft="true" android:layout_width="wrap_content" android:textSize="12.0sp" android:textColor="#788080" android:layout_height="wrap_content"/> <TextView android:id="@+id/user_age" android:layout_toRightOf="@id/user_sex" android:layout_width="wrap_content" android:textSize="12.0sp" android:textColor="#788080" android:layout_height="wrap_content"/> <TextView android:id="@+id/user_location" android:layout_toRightOf="@id/user_age" android:layout_width="wrap_content" android:textSize="12.0sp" android:textColor="#788080" android:layout_height="wrap_content"/> <TextView android:id="@+id/user_verifyinfo" android:layout_marginLeft="5.0dip" android:layout_alignParentLeft="true" android:layout_below="@id/user_sex" android:layout_width="fill_parent" android:textSize="12.0sp" android:textColor="#788080" android:layout_height="wrap_content"/> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:background="@drawable/panel_bg"> <TextView android:text="最新广播:" android:layout_width="fill_parent" android:layout_marginLeft="5.0dip" android:textSize="12.0sp" android:textColor="#788080" android:layout_height="wrap_content"/> <TextView android:id="@+id/user_time" android:layout_width="wrap_content" android:layout_marginLeft="3.0dip" android:layout_marginTop="10.0dip" android:textSize="8.0sp" android:textColor="#788080" android:layout_height="wrap_content" android:layout_alignParentRight="true"/> <TextView android:id="@+id/user_origtext" android:layout_width="fill_parent" android:layout_marginLeft="5.0dip" android:textSize="12.0sp" android:textColor="#788080" android:layout_height="wrap_content" android:layout_below="@id/user_time" android:layout_alignParentLeft="true"/> </RelativeLayout> </LinearLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_alignParentBottom="true"> <Button android:id="@+id/user_back_btn" android:layout_width="40.0dip" android:drawableTop="@drawable/btn_back_selector" android:background="@drawable/bottom_back_bg" android:layout_height="40.0dip" android:layout_alignParentLeft="true"/> <LinearLayout android:id="@+id/widget41" android:layout_marginLeft="60.0dip" android:layout_alignParentBottom="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_toRightOf="@id/user_back_btn"> <ImageView android:background="#f8f8f8" android:layout_width="1.0dip" android:layout_height="20.0dip" android:scaleType="fitCenter"/> <Button android:id="@+id/user_dialog_btn" android:layout_width="wrap_content" android:background="@drawable/bottom_bar_bg" android:layout_height="wrap_content" android:text="对话"/> <ImageView android:background="#f8f8f8" android:layout_width="1.0dip" android:layout_height="20.0dip" android:scaleType="fitCenter"/> <Button android:id="@+id/user_message_btn" android:layout_width="wrap_content" android:background="@drawable/bottom_bar_bg" android:layout_height="wrap_content" android:text="点评"/> </LinearLayout> <Button android:id="@+id/user_tohome_btn" android:layout_width="40.0dip" android:layout_height="40.0dip" android:drawableTop="@drawable/btn_home_selector" android:background="@drawable/bottom_home_bg" android:layout_alignParentRight="true"/> </RelativeLayout> </RelativeLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:paddingTop="3.0dip" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/userinfo_grid_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#586068"/> <TextView android:id="@+id/userinfo_grid_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#98a0a0"/> </LinearLayout> <ImageView android:id="@+id/userinfo_grid_image" android:src="#d0d0d8" android:visibility="invisible" android:layout_width="1.0dip" android:layout_height="30.0dip" android:layout_marginLeft="30.0dip"/> </LinearLayout>
发表评论
-
Android腾讯微薄客户端开发十五:终结篇(分享源代码)
2011-08-01 19:38 22729【有问题的同学请先仔 ... -
Android腾讯微薄客户端开发十四:首页menu菜单
2011-08-01 19:10 4664覆写onCreateOptionsMenu方法 @Over ... -
Android腾讯微薄客户端开发十三:提及篇(与我有关的微博)
2011-07-31 18:53 3080public class ReferActivity ext ... -
Android腾讯微薄客户端开发十二:博主的偶像
2011-07-31 18:34 2564点击收听,显示此博主的偶像列表,点击列表,将显示偶像的详情界 ... -
Android腾讯微薄客户端开发十一:博主的粉丝
2011-07-31 18:19 2321点击听众,显示博主的粉丝列表,点击列表中的粉丝,显示此粉丝详 ... -
Android腾讯微薄客户端开发十:博主广播篇
2011-07-31 17:59 2417点击广播,显示此博主所发表的所有微博 public cl ... -
Android腾讯微薄客户端开发八:微博查看(转播,对话,点评)
2011-07-31 17:39 2993如果是自己的微博,可以干掉它 下面三幅图是转播,对话以 ... -
Android腾讯微薄客户端开发七:图片加圆角以及时间处理工具类
2011-07-30 13:36 4016给图片加上圆角效果好看多了。 public class ... -
Android腾讯微博客户端开发六:给用户加VIP认证以及美化微博显示内容
2011-07-30 13:07 3573哈哈,通过VIP标志看到赵薇是冒牌的,李开复和冯小刚是正品。 ... -
Android腾讯微博客户端开发5:利用FootView实现ListView滑动动态加载实现分页
2011-07-27 01:34 11151老规矩,先上图 这张图片左边部分和右边部分还是有很大的不同,不 ... -
Android腾讯微博客户端开发四:微博发送篇(QQ表情,@搜索)
2011-07-25 00:55 6176凌晨发帖不容易啊, 有一个问题,谁做过android的自定义 ... -
Android腾讯微博客户端开发三:多账号管理的实现
2011-07-22 19:41 7615先看看效果。。 列表中的账号是保存在sqlite数据库中的, ... -
Android腾讯微博客户端开发二:相关工具篇
2011-07-22 18:19 5574工欲善其事,必先利其器。先给大家介绍3个我在做腾讯微博客户端开 ... -
Android腾讯微博客户端开发一:在下方的Tab的实现
2011-07-20 18:58 12546javaEye处女贴 下面的是res下drawabl ...
相关推荐
Android腾讯微博客户端开发
Android腾讯微博客户端开发五利用FootView实现ListView滑动动态
Android腾讯微博客户端开发一在下方的Tab的实现
Android 腾讯微博客户端源码
android腾讯微博客户端源码,功能基本齐全。
Android 腾讯微博客户端源码
android 实现腾讯微博客户端 源代码
Android 腾讯微博客户端源码.rar
Android程序研发源码Android 腾讯微博客户端源码.zip
Android腾讯微博客户端源码1.zip
Android 腾讯微博客户端源码1.rar
Android腾讯微博客户端源代码,大公司的Java程序,代码编写规范、注释丰富,可读性强,学习价值高。腾讯微博程序在Andorid程序中也算比较流行的程序,通过这个源代码你或许会学习到一些意想不到的Java Android编程...
腾讯微博客户端源码,可用于客户端类开发的联系
[腾讯微博Android客户端开发]课程文档及源代码
腾讯微博Android客户端开发全部实现代码,写得很详细
安卓版腾讯微博客户端源代码,虽然不是最新版,但很完整,必竟大公司开发的android应用软件,参考价值大代码架构和规范都做的很不错,做同类客户端的朋友可考虑参考。