- 浏览: 936365 次
- 性别:
- 来自: 山西
文章分类
最新评论
-
白小默:
你好 可以提供下源码DEMO吗,不知为何,我导出来的excel ...
jxls 使用模板文件导出生成excel -
zkzqzzz:
博主威武!
让微信二维码扫描您的APK -
zkzqzzz:
感谢博主 原来那些类都不是必须的 或者自己写!!博主真棒 ...
抢红包插件实现原理浅析 -
zkzqzzz:
博主 请问你的其他类在哪里呢?
抢红包插件实现原理浅析 -
zkzqzzz:
其他类在哪呢?
抢红包插件实现原理浅析
点击收听,显示此博主的偶像列表,点击列表,将显示偶像的详情界面
- public class IdolActivity extends ListActivity implements OnItemClickListener{
- private DataHelper dataHelper;
- private UserInfo user;
- private MyWeiboSync weibo;
- private Handler handler;
- private AsyncImageLoader asyncImageLoader;
- private IdolThread thread;
- private ProgressDialog progressDialog;
- private JSONArray array;
- private IdolAdapter adapter;
- private ListView listView;
- private String name;
- private String currentNick;//当前界面的昵称
- private View top_panel;
- private Button top_btn_left;
- private Button top_btn_right;
- private TextView top_title;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.idol);
- setUpViews();//设置view
- setUpListeners();//设置listenter
- asyncImageLoader = new AsyncImageLoader();
- dataHelper = new DataHelper(IdolActivity.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");
- top_title.setText(currentNick+"的偶像");
- progressDialog = new ProgressDialog(IdolActivity.this);// 生成一个进度条
- progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- progressDialog.setTitle("请稍等");
- progressDialog.setMessage("正在读取数据中!");
- handler = new IdolHandler();
- thread = new IdolThread();
- thread.start();//开启一个线程获取数据
- progressDialog.show();
- }
- private void setUpViews(){
- listView = getListView();
- top_panel = (View)findViewById(R.id.idol_top);
- top_btn_left = (Button)top_panel.findViewById(R.id.top_btn_left);
- top_btn_right = (Button)top_panel.findViewById(R.id.top_btn_right);
- top_title = (TextView)top_panel.findViewById(R.id.top_title);
- }
- private void setUpListeners(){
- listView.setOnItemClickListener(this);
- }
- class IdolThread extends Thread {
- @Override
- public void run() {
- String jsonStr = weibo.getIdols(weibo.getAccessTokenKey(), weibo.getAccessTokenSecrect(), 20, 0, name);
- try {
- JSONObject dataObj = new JSONObject(jsonStr).getJSONObject("data");
- array = dataObj.getJSONArray("info");
- } catch (JSONException e) {
- e.printStackTrace();
- }
- //通知handler处理数据
- Message msg = handler.obtainMessage();
- handler.sendMessage(msg);
- }
- }
- class IdolHandler extends Handler {
- @Override
- public void handleMessage(Message msg){
- adapter = new IdolAdapter(IdolActivity.this, array);
- listView.setAdapter(adapter);
- progressDialog.dismiss();// 关闭进度条
- }
- }
- class IdolAdapter extends BaseAdapter {
- private Context context;
- private LayoutInflater inflater;
- private JSONArray array;
- public IdolAdapter(Context context, JSONArray array) {
- super();
- this.context = context;
- this.array = array;
- this.inflater = LayoutInflater.from(context);
- }
- @Override
- public int getCount() {
- return array.length();
- }
- @Override
- public Object getItem(int position) {
- return array.opt(position);
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- asyncImageLoader = new AsyncImageLoader();
- IdolViewHolder viewHolder = new IdolViewHolder();
- JSONObject data = (JSONObject)array.opt(position);
- convertView = inflater.inflate(R.layout.idol_list_item, null);
- viewHolder.idol_headicon = (ImageView) convertView.findViewById(R.id.idol_headicon);
- viewHolder.idol_nick = (TextView) convertView.findViewById(R.id.idol_nick);
- viewHolder.idol_name = (TextView) convertView.findViewById(R.id.idol_name);
- Drawable cachedImage = null;
- if(data!=null){
- try {
- convertView.setTag(data.get("name"));
- viewHolder.idol_nick.setText(data.getString("nick"));
- viewHolder.idol_name.setText("@"+data.getString("name"));
- //异步加载图片
- cachedImage = asyncImageLoader.loadDrawable(data.getString("head")+"/100",viewHolder.idol_headicon, new ImageCallback(){
- @Override
- public void imageLoaded(Drawable imageDrawable,ImageView imageView, String imageUrl) {
- imageView.setImageDrawable(imageDrawable);
- }
- });
- if(cachedImage == null) {
- viewHolder.idol_headicon.setImageResource(R.drawable.icon);
- }
- } catch (JSONException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return convertView;
- }
- }
- static class IdolViewHolder {
- private ImageView idol_headicon;
- private TextView idol_nick;
- private TextView idol_name;
- }
- @Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
- Intent intent = new Intent(IdolActivity.this,UserInfoActivity.class);
- try {
- JSONObject fansInfo = (JSONObject)array.opt(position);
- JSONArray tweets = fansInfo.getJSONArray("tweet");
- JSONObject tweet = null;
- if(tweets!=null&&tweets.length()>0){
- tweet = (JSONObject)tweets.opt(0);
- intent.putExtra("origtext", tweet.getString("text"));
- intent.putExtra("timestamp", TimeUtil.getStandardTime(tweet.getLong("timestamp")));
- }
- intent.putExtra("name", fansInfo.getString("name"));
- intent.putExtra("nick", fansInfo.getString("nick"));
- } catch (JSONException e) {
- e.printStackTrace();
- }
- startActivity(intent);//跳转到用户信息界面
- }
- }
public class IdolActivity extends ListActivity implements OnItemClickListener{ private DataHelper dataHelper; private UserInfo user; private MyWeiboSync weibo; private Handler handler; private AsyncImageLoader asyncImageLoader; private IdolThread thread; private ProgressDialog progressDialog; private JSONArray array; private IdolAdapter adapter; private ListView listView; private String name; private String currentNick;//当前界面的昵称 private View top_panel; private Button top_btn_left; private Button top_btn_right; private TextView top_title; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.idol); setUpViews();//设置view setUpListeners();//设置listenter asyncImageLoader = new AsyncImageLoader(); dataHelper = new DataHelper(IdolActivity.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"); top_title.setText(currentNick+"的偶像"); progressDialog = new ProgressDialog(IdolActivity.this);// 生成一个进度条 progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setTitle("请稍等"); progressDialog.setMessage("正在读取数据中!"); handler = new IdolHandler(); thread = new IdolThread(); thread.start();//开启一个线程获取数据 progressDialog.show(); } private void setUpViews(){ listView = getListView(); top_panel = (View)findViewById(R.id.idol_top); top_btn_left = (Button)top_panel.findViewById(R.id.top_btn_left); top_btn_right = (Button)top_panel.findViewById(R.id.top_btn_right); top_title = (TextView)top_panel.findViewById(R.id.top_title); } private void setUpListeners(){ listView.setOnItemClickListener(this); } class IdolThread extends Thread { @Override public void run() { String jsonStr = weibo.getIdols(weibo.getAccessTokenKey(), weibo.getAccessTokenSecrect(), 20, 0, name); try { JSONObject dataObj = new JSONObject(jsonStr).getJSONObject("data"); array = dataObj.getJSONArray("info"); } catch (JSONException e) { e.printStackTrace(); } //通知handler处理数据 Message msg = handler.obtainMessage(); handler.sendMessage(msg); } } class IdolHandler extends Handler { @Override public void handleMessage(Message msg){ adapter = new IdolAdapter(IdolActivity.this, array); listView.setAdapter(adapter); progressDialog.dismiss();// 关闭进度条 } } class IdolAdapter extends BaseAdapter { private Context context; private LayoutInflater inflater; private JSONArray array; public IdolAdapter(Context context, JSONArray array) { super(); this.context = context; this.array = array; this.inflater = LayoutInflater.from(context); } @Override public int getCount() { return array.length(); } @Override public Object getItem(int position) { return array.opt(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { asyncImageLoader = new AsyncImageLoader(); IdolViewHolder viewHolder = new IdolViewHolder(); JSONObject data = (JSONObject)array.opt(position); convertView = inflater.inflate(R.layout.idol_list_item, null); viewHolder.idol_headicon = (ImageView) convertView.findViewById(R.id.idol_headicon); viewHolder.idol_nick = (TextView) convertView.findViewById(R.id.idol_nick); viewHolder.idol_name = (TextView) convertView.findViewById(R.id.idol_name); Drawable cachedImage = null; if(data!=null){ try { convertView.setTag(data.get("name")); viewHolder.idol_nick.setText(data.getString("nick")); viewHolder.idol_name.setText("@"+data.getString("name")); //异步加载图片 cachedImage = asyncImageLoader.loadDrawable(data.getString("head")+"/100",viewHolder.idol_headicon, new ImageCallback(){ @Override public void imageLoaded(Drawable imageDrawable,ImageView imageView, String imageUrl) { imageView.setImageDrawable(imageDrawable); } }); if(cachedImage == null) { viewHolder.idol_headicon.setImageResource(R.drawable.icon); } } catch (JSONException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } return convertView; } } static class IdolViewHolder { private ImageView idol_headicon; private TextView idol_nick; private TextView idol_name; } @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { Intent intent = new Intent(IdolActivity.this,UserInfoActivity.class); try { JSONObject fansInfo = (JSONObject)array.opt(position); JSONArray tweets = fansInfo.getJSONArray("tweet"); JSONObject tweet = null; if(tweets!=null&&tweets.length()>0){ tweet = (JSONObject)tweets.opt(0); intent.putExtra("origtext", tweet.getString("text")); intent.putExtra("timestamp", TimeUtil.getStandardTime(tweet.getLong("timestamp"))); } intent.putExtra("name", fansInfo.getString("name")); intent.putExtra("nick", fansInfo.getString("nick")); } catch (JSONException e) { e.printStackTrace(); } startActivity(intent);//跳转到用户信息界面 } }
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffffff"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <include android:id="@+id/idol_top" layout="@layout/top_panel" android:layout_alignParentTop="true"/>
- <ListView android:id="@id/android:list" android:layout_below="@id/idol_top" android:layout_width="fill_parent" android:cacheColorHint="#00000000"
- android:layout_height="fill_parent" android:layout_weight="1" android:divider="@drawable/list_divider"/>
- <RelativeLayout android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_alignParentBottom="true">
- <Button android:id="@+id/idol_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"/>
- <Button android:id="@+id/idol_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"?> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffffff" xmlns:android="http://schemas.android.com/apk/res/android"> <include android:id="@+id/idol_top" layout="@layout/top_panel" android:layout_alignParentTop="true"/> <ListView android:id="@id/android:list" android:layout_below="@id/idol_top" android:layout_width="fill_parent" android:cacheColorHint="#00000000" android:layout_height="fill_parent" android:layout_weight="1" android:divider="@drawable/list_divider"/> <RelativeLayout android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_alignParentBottom="true"> <Button android:id="@+id/idol_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"/> <Button android:id="@+id/idol_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:paddingTop="3.0dip" android:orientation="horizontal" android:background="@drawable/listitem_selector" android:layout_width="fill_parent" android:layout_height="wrap_content">
- <RelativeLayout android:layout_width="50.0dip" android:layout_height="50.0dip" android:layout_weight="0.0">
- <ImageView android:id="@+id/idol_headicon" android:layout_width="45.0dip" android:layout_height="45.0dip" android:scaleType="fitCenter" android:layout_centerInParent="true" />
- </RelativeLayout>
- <RelativeLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="4.0dip" android:layout_weight="1.0">
- <TextView android:id="@+id/idol_nick" android:textColor="#000000" android:layout_width="wrap_content" android:layout_height="32.0dip" android:textSize="14.0sp" android:layout_alignParentLeft="true"/>
- <TextView android:id="@+id/idol_name" android:layout_marginLeft="6.0dip" android:layout_below="@id/idol_nick" android:textColor="#ff000000" android:layout_width="wrap_content" android:layout_height="32.0dip" android:textSize="8.0sp" android:layout_alignParentLeft="true"/>
- </RelativeLayout>
- </LinearLayout>
- http://helloandroid.iteye.com/blog/1136761
发表评论
-
Android客户端代码保护技术-完整性校验
2018-01-08 17:10 1256由于Android系统固有的缺陷、Android应用分发 ... -
android开发中手动v2签名实现方法
2018-01-08 10:31 1016用v2签名前要进行v1签名或zipalign。 1. z ... -
webview支持LocalStorage本地存储
2017-03-31 10:30 1364//允许JavaScript执行 ... -
七步配置phonegap+cordova+ionic开发环境
2016-12-19 16:21 695本文讲的是Android混合 ... -
梆梆加固破解
2016-10-13 09:01 1505本文假设你已经使用过梆梆加固,手头至少有个一个通过梆梆加固后 ... -
android zxing 扫描二维码 横屏转竖屏
2016-09-14 15:41 0Zxing 竖屏切换 Android 在google上下 ... -
封装Volley使Volley的每个请求都自动保存和发送Cookie
2016-09-14 10:57 0思路很简单,每次请求获取到服务器返回的response就解 ... -
Android二维码ZXing扫描区域大小的调整,提高扫描速度
2016-09-14 10:48 2641Zxing本身默认的扫图区域最大只有 360*480 ... -
解决Android二维码扫描ZXing竖屏拉伸变长闪退扫描区域小等问题
2016-09-14 10:42 1227Android 基于google Zxing实现二维码、条形 ... -
Android平台下利用zxing实现二维码开发
2016-09-14 09:25 482现在走在大街小巷都能看到二维码,而且最近由于项目需要,所以研 ... -
Zxing扫描二维码
2016-09-14 09:24 660摘要 android Zxing扫描二维码 横竖屏 ... -
Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
2016-09-14 09:18 505转载请注明出处:http://blog.csdn.net/x ... -
React Native应用部署/热更新-CodePush最新集成总结
2016-08-02 11:06 566本文出自《React Native学习笔记》系列文章。 ... -
让微信二维码扫描您的APK
2016-07-27 11:26 1504二维码深入人心,很多App都在官网挂出了可以扫描下载apk的 ... -
Activity类的runOnUiThread方法
2016-07-22 10:40 767[javascript] view plain c ... -
Can't create handler inside thread that has not called Looper.prepare()
2016-07-22 10:24 630错误信息:在Android开发中,如果在一个Thread中启 ... -
Android编程之解决android-support-v4打包问题
2016-07-21 09:27 549如果工程引入了android-support-v4的jar类 ... -
Android 编程下的代码混淆之(android-support-v4.jar)
2016-07-21 09:24 394项目在代码混淆过程中如果引用了第三方 Jar 包,需要在混淆 ... -
phoneGap可行性分析
2016-07-20 16:25 5131 移动应用现状 移动应用产品往往常 ... -
梆梆SDKs详细分析(1) - 防界面劫持SDK
2016-07-20 10:23 754前言 前段时间,国外知名的安全公司fireeye发 ...
相关推荐
腾讯人脸识别多版本接口文档,需要的下载,本文只负责转摘,不做商业用途,需要的可以下载,里面涵盖腾讯人脸的多个文档,这个是我之前做的腾讯人脸项目所用到的,腾讯官方只给到在线版的,我就自己弄了个PDF
Eclipse中用SWT和JFace开发入门-转摘 .doc
android 布局参数中文注释说明 两张图片截图,仅对linerlayout 及RelativeLayout参数说明! 网络转摘!仅供学习!
有很多的朋友给自己硬盘新建分区都喜欢用第三方软件,我想原因是在XP系统下只能在安装系统时才能进行分区,一旦系统做好之后要想新建分区就必须...本文转摘自『蓝派网』http://www.lan27.com/Article/201101/10965.htm
公司控制权之争及公司股权设计模式转摘.doc
一、开发环境:pb11.2 8669 二、pb的webservice程序必须置于英文目录下,含中文路径时部署会出错; 三、代码只要改一个地方: n_webservice对象的of_retrieve函数中 sqlca.logpass设置为你测试数据库的sa对应密码即可 四...
新零售时代,小卖家如何迅速做出销量(转摘).zip
完全平方公式变形的应用练习题_2(转摘).doc
新零售时代,小卖家如何迅速做出销量(转摘).doc
新零售时代,小卖家如何迅速做出销量(转摘)-知识杂货店.doc
华为从事通信网络技术与产品的研究、开发、生产与销售,是中国电信市场的主要供应商之一,并已成功进入全球电信市场。每年华为都要在各大高校招聘大批的应界生,特别是华中科技大学。 下面据说是华为公司的笔试题...
很多可能在转摘过程中失真或未经验证就被转摘,真正使用时却不行,也由此决定自己全方位试验一下,努力还是没有白费,虽然最终得出的结果是很简单的,但其过程对于一个新学AJAX的人来说,真是挺累。欢迎您在使用过程...
这个是我从网上找到的资料,现在共享给大家,希望能帮助到大家。
在当今快速的开发环境中,应用程序的测试总是处于次要地位。DataFactory是一种强的的数据产生器,它允许开发人员和QA很容易产生百万行有意义的正确的测试数据库, DataFactory 首先读取一个数据库方案,用户随后点击...
转摘:Microsoft Office Access(前名 Microsoft Access)是由微软发布的关联式数据库管理系统。它结合了 Microsoft Jet Database Engine 和 图形用户界面两项特点,是 Microsoft Office的成员之一。 Access能够...
本文为转摘!!!!!!!!!!
本站声明:此文章来源于网络,如果未署名,可能因为此文被转摘多次,原作者不详。本站转载时稍作整理。如果原作者认为侵权,请联系我。我将在第一时间按其要求做出处理,并消除影响。
移动端开发(转摘jtyjty99999/mobileTech) ECMA-262,第 5 版 外链(即ES5) ECMAScript5.1中文版 外链(很详细教程) 前端技能汇总 外链(朴灵git) 在线预览word文档 颜色互转 MIME 类型 常用算法 async和defer...
除非特别声明,原文版权归作者所有,如有转摘请注明原作者以及译者(FPGA技术网)信息。本译文会不断更新,要获得本译文的最新版本请查看本文的在线版本SystemVerilog 3.1a 语言参考手册。 由于时间及译者水平所限,...
说明:本书籍转摘自互联网,为广大ASP.NET爱好者提供更好的资源。