コード例 #1
0
ファイル: LittleHelperAdapter.java プロジェクト: omusico/hand
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final TBNews tbNews = mList.get(position);
    ViewHolder holder = null;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.adapter_little_helper, null);

      holder = new ViewHolder();
      holder.iv_icon = (ImageView) convertView.findViewById(R.id.id_iv_icon);
      holder.tv_title = (TextView) convertView.findViewById(R.id.id_tv_title);
      holder.tv_desc = (TextView) convertView.findViewById(R.id.id_tv_desc);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.tv_title.setText(tbNews.getTitle());
    holder.tv_desc.setText(tbNews.getDesc());
    holder.iv_icon.setImageBitmap(tbNews.getBitmap());

    convertView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent i = new Intent(mContext, LittleHelperWebViewActivity.class);
            i.putExtra("loadUrl", tbNews.getUrl());
            mContext.startActivity(i);
          }
        });

    return convertView;
  }
コード例 #2
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = LayoutInflater.from(context).inflate(R.layout.item_history_list, null);
      holder.ll = (LinearLayout) convertView.findViewById(R.id.ll);
      holder.iv_icon = (ImageView) convertView.findViewById(R.id.iv_icon);
      holder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
      holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
      holder.btn_share = (Button) convertView.findViewById(R.id.btn_share);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    if (historyList.get(getCount() - position - 1).getType() == 1) {
      holder.iv_icon.setImageResource(R.drawable.browser_icon);
      // holder.tv_title.setText( context.getString( R.string.string_interlinkage ) );
    } else {
      holder.iv_icon.setImageResource(R.drawable.text_icon);
      // holder.tv_title.setText( context.getString( R.string.string_text ) );
    }
    holder.tv_title.setText(historyList.get(getCount() - position - 1).getCurrtime());
    holder.tv_content.setText(historyList.get(getCount() - position - 1).getText());
    holder.ll.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (historyList.get(getCount() - position - 1).getType() == 1) {
              Uri uri = Uri.parse(historyList.get(getCount() - position - 1).getText());
              Intent intent = new Intent(Intent.ACTION_VIEW, uri);
              context.startActivity(intent);
            } else {
              AlertDialog.Builder builder = new Builder(context);
              builder.setMessage(historyList.get(getCount() - position - 1).getText());
              builder.setTitle(context.getResources().getString(R.string.string_text));
              builder.setNegativeButton(android.R.string.ok, null);
              AlertDialog dialog = builder.create();
              dialog.show();
            }
          }
        });
    holder.btn_share.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Log.v("QrCode", "share click");
            Intent shareIntent = new Intent(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.share_title));
            shareIntent.putExtra(
                Intent.EXTRA_TEXT, historyList.get(getCount() - position - 1).getText());
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(shareIntent);
          }
        });
    return convertView;
  }
コード例 #3
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      // 设置item的view

      ViewHolder holder = null;
      if (convertView == null) {
        convertView = View.inflate(SelectContactActivity.this, R.layout.lv_item_contact, null);

        holder = new ViewHolder();
        holder.iv_icon = (ImageView) convertView.findViewById(R.id.lv_iv_icon);
        holder.tv_name = (TextView) convertView.findViewById(R.id.lv_iv_name);
        holder.tv_num = (TextView) convertView.findViewById(R.id.lv_iv_num);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }

      ContactBean bean = list.get(position);
      bean.icon = ContactUtils.getContactPhoto(SelectContactActivity.this, bean.contactID);
      if (bean.icon == null) {
        holder.iv_icon.setImageResource(R.drawable.ic_contact);
      } else {
        holder.iv_icon.setImageBitmap(bean.icon);
      }
      holder.tv_name.setText(bean.name);
      holder.tv_num.setText(bean.num);
      return convertView;
    }
コード例 #4
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   TaskInfo taskInfo;
   if (position == 0) {
     TextView tv = new TextView(getApplicationContext());
     tv.setTextColor(Color.WHITE);
     tv.setBackgroundColor(Color.GRAY);
     tv.setText("用户进程(" + userTaskInfos.size() + ")");
     return tv;
   } else if (position == (userTaskInfos.size() + 1)) {
     TextView tv = new TextView(getApplicationContext());
     tv.setTextColor(Color.WHITE);
     tv.setBackgroundColor(Color.GRAY);
     tv.setText("系统进程(" + systemTaskInfos.size() + ")");
     return tv;
   } else if (position <= userTaskInfos.size()) {
     taskInfo = userTaskInfos.get(position - 1);
   } else {
     taskInfo = systemTaskInfos.get(position - 1 - userTaskInfos.size() - 1);
   }
   View view;
   ViewHolder holder;
   if (convertView != null && convertView instanceof RelativeLayout) {
     view = convertView;
     holder = (ViewHolder) view.getTag();
   } else {
     view = View.inflate(getApplicationContext(), R.layout.list_task_item, null);
     holder = new ViewHolder();
     holder.iv_icon = (ImageView) view.findViewById(R.id.iv_icon);
     holder.tv_name = (TextView) view.findViewById(R.id.tv_name);
     holder.tv_memsize = (TextView) view.findViewById(R.id.tv_memsize);
     holder.cb = (CheckBox) view.findViewById(R.id.cb);
     view.setTag(holder);
   }
   holder.iv_icon.setImageDrawable(taskInfo.getIcon());
   holder.tv_name.setText(taskInfo.getName());
   holder.tv_memsize.setText(
       Formatter.formatFileSize(getApplicationContext(), taskInfo.getMemsize()));
   holder.cb.setChecked(taskInfo.isChecked());
   if (taskInfo.getPackname().equals(getPackageName())) {
     holder.cb.setVisibility(View.INVISIBLE);
   } else {
     holder.cb.setVisibility(View.VISIBLE);
   }
   return view;
 }
コード例 #5
0
ファイル: SpinnerView.java プロジェクト: deanxd/selfkongjian
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder = null;
      if (convertView == null) {
        convertView = View.inflate(getContext(), R.layout.item_lv, null);
        holder = new ViewHolder();

        holder.iv_icon = (ImageView) convertView.findViewById(R.id.iv_icon);
        holder.iv_delete = (ImageView) convertView.findViewById(R.id.iv_delete);
        holder.tv_number = (TextView) convertView.findViewById(R.id.tv_number);

        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }

      // 数据

      final SpinnerData data = datas.get(position);

      if (data.icon_id != -1) {
        // 有图片
        holder.iv_icon.setImageResource(data.icon_id);
      } else if (data.icon != null) {
        holder.iv_icon.setImageDrawable(data.icon);
      }
      holder.tv_number.setText(data.number);

      // 删除
      holder.iv_delete.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              datas.remove(data);
              // 更新界面
              mAdapter.notifyDataSetChanged();
            }
          });
      return convertView;
    }
コード例 #6
0
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub'
			AppInfo newappInfo;
			
			//用户程序数量
			if (position == 0) {
				TextView tv = new TextView(getApplicationContext());
				tv.setTextColor(Color.WHITE);
				tv.setBackgroundColor(Color.GRAY);
				tv.setText("用户程序:" + userAppInfos.size() + "个");
				return tv;
			} else if (position == userAppInfos.size() + 1) {
				TextView tv = new TextView(getApplicationContext());
				tv.setTextColor(Color.WHITE);
				tv.setBackgroundColor(Color.GRAY);
				tv.setText("系统程序:" + systemAppInfos.size() + "个");
				return tv;
			} else if (position <= userAppInfos.size()) {
				//用户程序
				//因为多了一个TextView的文本占用了一个位置
				int newposition = position - 1;
				newappInfo = userAppInfos.get(newposition);
			} else {
				//系统程序
				
				int newposition = position - 1 - userAppInfos.size() - 1;
				newappInfo = systemAppInfos.get(newposition);
			}
			

			View view;
			ViewHolder holder;
			
			//复用缓存的view对象,并且判断缓存的对象类型,避免复用不合适的类型
			if (convertView != null && convertView instanceof RelativeLayout) {
				view = convertView;
				holder = (ViewHolder) view.getTag();
			} else {
				view = View.inflate(getApplicationContext(), R.layout.list_item_appinfo, null);
				holder = new ViewHolder();
				holder.iv_icon = (ImageView) view.findViewById(R.id.iv_app_icon);
				holder.tv_name = (TextView) view.findViewById(R.id.tv_app_name);
				holder.tv_location = (TextView) view.findViewById(R.id.tv_app_location);
				holder.iv_status = (ImageView) view.findViewById(R.id.iv_status);
				view.setTag(holder);
				
			}
			
//			if (position < userAppInfos.size()) {
//				//用户程序显示位置
//				newappInfo = userAppInfos.get(position);
//			} else {
//				//系统程序显示位置
//				int newposition = position - userAppInfos.size();
//				newappInfo = systemAppInfos.get(newposition);
//			}
			
			holder.iv_icon.setImageDrawable(newappInfo.getIcon());
			holder.tv_name.setText(newappInfo.getName());
			
			if (newappInfo.isInRom()) {
				holder.tv_location.setText("手机内存");
			} else {
				holder.tv_location.setText("外部存储");
			}
			
			
			
			if (dao.find(newappInfo.getPackname())) {
				holder.iv_status.setImageResource(R.drawable.lock);
			} else {
				holder.iv_status.setImageResource(R.drawable.unlock);
			}
			
			
			
			return view;
		}
コード例 #7
0
ファイル: AppLockActivity.java プロジェクト: limitlc/HMPHONE
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      final View view;
      ViewHolder holder;
      if (convertView != null && convertView instanceof RelativeLayout) {
        view = convertView;
        holder = (ViewHolder) view.getTag();
      } else {
        view = View.inflate(getApplicationContext(), R.layout.list_applock_item, null);
        holder = new ViewHolder();
        holder.iv_icon = (ImageView) view.findViewById(R.id.iv_icon);
        holder.tv_name = (TextView) view.findViewById(R.id.tv_name);
        holder.iv_status = (ImageView) view.findViewById(R.id.iv_status);
        view.setTag(holder);
      }
      final AppInfo appinfo;
      if (unlockflag) {
        holder.iv_status.setBackgroundResource(R.drawable.lock);
        appinfo = unlockAppInfos.get(position);
      } else {
        holder.iv_status.setBackgroundResource(R.drawable.unlock);
        appinfo = lockedAppInfos.get(position);
      }
      holder.iv_icon.setImageDrawable(appinfo.getIcon());
      holder.tv_name.setText(appinfo.getName());
      holder.iv_status.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              // 从当前界面移除item
              // 把这个条目的包名给存到数据库
              if (unlockflag) { // 未加锁列表
                TranslateAnimation ta =
                    new TranslateAnimation(
                        Animation.RELATIVE_TO_SELF, 0,
                        Animation.RELATIVE_TO_SELF, 1.0f,
                        Animation.RELATIVE_TO_SELF, 0,
                        Animation.RELATIVE_TO_SELF, 0);
                ta.setDuration(500);
                view.startAnimation(ta);
                // 让主线程在这等待500毫秒
                // 若干秒时间后 在主线程执行逻辑
                new Handler()
                    .postDelayed(
                        new Runnable() {
                          @Override
                          public void run() {
                            // 会在主线程里面执行。
                            unlockAppInfos.remove(position);
                            dao.add(appinfo.getPackname());
                            lockedAppInfos.add(appinfo);
                            unlockadapter.notifyDataSetChanged();
                            lockedadapter.notifyDataSetChanged();
                          }
                        },
                        500);

              } else {
                TranslateAnimation ta =
                    new TranslateAnimation(
                        Animation.RELATIVE_TO_SELF, 0,
                        Animation.RELATIVE_TO_SELF, -1.0f,
                        Animation.RELATIVE_TO_SELF, 0,
                        Animation.RELATIVE_TO_SELF, 0);
                ta.setDuration(500);
                view.startAnimation(ta);
                new Handler()
                    .postDelayed(
                        new Runnable() {

                          @Override
                          public void run() {
                            lockedAppInfos.remove(position);
                            dao.delete(appinfo.getPackname());
                            unlockAppInfos.add(appinfo);
                            unlockadapter.notifyDataSetChanged();
                            lockedadapter.notifyDataSetChanged();
                          }
                        },
                        500);
              }
            }
          });
      return view;
    }
コード例 #8
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (position == 0) {
        TextView textView = new TextView(AppManagerActivity.this);

        textView.setBackgroundColor(Color.LTGRAY);
        textView.setText("user app:" + userApp.size());
        return textView;
      } else if (position == userApp.size() + 1) {
        TextView textView = new TextView(AppManagerActivity.this);

        textView.setBackgroundColor(Color.LTGRAY);
        textView.setText("system app:" + systemApp.size());
        return textView;
      }
      // get block list object
      final AppInfo info;
      if (position < userApp.size() + 1) {
        info = userApp.get(position - 1);
      } else {
        info = systemApp.get(position - userApp.size() - 1 - 1);
      }

      final ViewHolder holder;

      if (convertView != null && convertView instanceof LinearLayout) {
        holder = (ViewHolder) convertView.getTag();
      } else {
        convertView = View.inflate(AppManagerActivity.this, R.layout.listview_item_app, null);

        holder = new ViewHolder();
        holder.iv_icon = (ImageView) convertView.findViewById(R.id.iv_icon);
        holder.tv_app_name = (TextView) convertView.findViewById(R.id.tv_app_name);
        holder.tv_version_size = (TextView) convertView.findViewById(R.id.tv_version_size);
        holder.iv_uninstall = (ImageView) convertView.findViewById(R.id.iv_uninstall);
        convertView.setTag(holder);
      }

      String apkName = info.getApkName();
      holder.tv_app_name.setText(apkName);

      String tv_version_size = info.getVersion() + ", " + info.getSize();
      holder.tv_version_size.setText(tv_version_size);

      Drawable drawable = info.getIcon();
      holder.iv_icon.setImageDrawable(drawable);

      holder.iv_uninstall.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent =
                  new Intent(
                      "android.intent.action.DELETE",
                      Uri.parse("package:" + info.getPackageName()));
              startActivity(intent);
            }
          });

      return convertView;
    }