List of usage examples for android.view View setTag
public void setTag(final Object tag)
From source file:cn.com.teamlink.workbench.ExplorerActivity.java
public void onCreate(Bundle savedInstanceState) { // /* w ww . j a va 2 s .c o m*/ requestWindowFeature(Window.FEATURE_NO_TITLE); // ? setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_explorer); try { gridview = (GridView) findViewById(R.id.explorer_grid_view); gridViewListItems = new ArrayList<HashMap<String, String>>(); /* gridViewListItemAdapter = new SimpleAdapter( this, // ??? gridViewListItems, R.layout.explorer_item, new String[]{"item_text"}, new int[]{R.id.item_text_view} ); */ gridViewListItemAdapter = new BaseAdapter() { @Override public int getCount() { return gridViewListItems.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public int getItemViewType(int position) { // TODO Auto-generated method stub Map<String, String> item = gridViewListItems.get(position); if (item.get("type").equals("GRID_HEADER")) { return 1; } return 0; } @Override public int getViewTypeCount() { return 2; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (getItemViewType(position) == 0) { GridViewHeaderHolder gridViewHeaderHolder = null; if (convertView != null) { gridViewHeaderHolder = (GridViewHeaderHolder) convertView.getTag(); } else { gridViewHeaderHolder = new GridViewHeaderHolder(); LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); convertView = inflater.inflate(R.layout.explorer_item, parent, false); gridViewHeaderHolder.itemTextView = (TextView) convertView .findViewById(R.id.item_text_view); convertView.setTag(gridViewHeaderHolder); } gridViewHeaderHolder.itemTextView .setText(gridViewListItems.get(position).get("item_text").toString()); } else { GridViewItemHolder gridViewItemHolder = null; if (convertView != null) { gridViewItemHolder = (GridViewItemHolder) convertView.getTag(); } else { gridViewItemHolder = new GridViewItemHolder(); LayoutInflater inflater = LayoutInflater.from(getApplicationContext()); convertView = inflater.inflate(R.layout.explorer_item, parent, false); convertView.setBackgroundResource(R.color.deepGray); gridViewItemHolder.itemTextView = (TextView) convertView .findViewById(R.id.item_text_view); convertView.setTag(gridViewItemHolder); } gridViewItemHolder.itemTextView .setText(gridViewListItems.get(position).get("item_text").toString()); } return convertView; } }; // gridview.setAdapter(gridViewListItemAdapter); // ?? gridview.setOnItemClickListener(new ItemClickListener()); // addHeader(); // ? addData(); } catch (Exception e) { Dialog alertDialog = new AlertDialog.Builder(this).setTitle("??").setMessage(e.getMessage()) .setIcon(R.mipmap.ic_launcher).create(); alertDialog.show(); } try { // ?? String fileName = "fileDemo.txt"; // ?? FileOutputStream fos = openFileOutput(fileName, Context.MODE_PRIVATE); String text = "Some data"; // ? fos.write(text.getBytes()); // ? fos.flush(); // FileOutputStream fos.close(); // String fileName = "fileDemo.txt"; FileInputStream fis = openFileInput(fileName); byte[] readBytes = new byte[fis.available()]; while (fis.read(readBytes) != -1) { } Dialog alertDialog = new AlertDialog.Builder(this).setTitle("??").setMessage(new String(readBytes)) .setIcon(R.mipmap.ic_launcher).create(); alertDialog.show(); } catch (Exception e) { Dialog alertDialog = new AlertDialog.Builder(this).setTitle("??") .setMessage(e.getLocalizedMessage()).setIcon(R.mipmap.ic_launcher).create(); alertDialog.show(); /* Dialog alertDialog = new AlertDialog.Builder(this). setTitle(""). setMessage("???"). setIcon(R.mipmap.ic_launcher). setPositiveButton( "", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } } ). setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }). setNeutralButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }). create(); alertDialog.show(); */ /* final String[] arrayFruit = new String[]{"", "?", "?", ""}; Dialog alertDialog = new AlertDialog .Builder(this). setTitle("??"). setIcon(R.mipmap.ic_launcher) .setItems( arrayFruit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(ExplorerActivity.this, arrayFruit[which], Toast.LENGTH_SHORT).show(); } } ) .setNegativeButton( "?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } } ).create(); alertDialog.show(); */ /* // int selectedFruitIndex = 0; final String[] arrayFruit = new String[]{"", "?", "?", ""}; Dialog alertDialog = new AlertDialog.Builder(this) .setTitle("??") .setIcon(R.mipmap.ic_launcher) .setSingleChoiceItems(arrayFruit, 0, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { selectedFruitIndex = which; } }) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(Dialog_AlertDialogDemoActivity.this, arrayFruit[selectedFruitIndex], Toast.LENGTH_SHORT).show(); } }).setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).create(); alertDialog.show(); */ /* final String[] arrayFruit = new String[]{"", "?", "?", ""}; final boolean[] arrayFruitSelected = new boolean[]{true, true, false, false}; Dialog alertDialog = new AlertDialog.Builder(this) .setTitle("??") .setIcon(R.mipmap.ic_launcher) .setMultiChoiceItems(arrayFruit, arrayFruitSelected, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { arrayFruitSelected[which] = isChecked; } }) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < arrayFruitSelected.length; i++) { if (arrayFruitSelected[i] == true) { stringBuilder.append(arrayFruit[i] + "?"); } } Toast.makeText(ExplorerActivity.this, stringBuilder.toString(), Toast.LENGTH_SHORT).show(); } }) .setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).create(); alertDialog.show(); */ /* // ?View LayoutInflater layoutInflater = LayoutInflater.from(this); View myLoginView = layoutInflater.inflate(R.layout.login, null); Dialog alertDialog = new AlertDialog.Builder(this) .setTitle("") .setIcon(R.mipmap.ic_launcher) .setView(myLoginView) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }) .setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).create(); alertDialog.show(); */ } }
From source file:com.siso.app.adapter.MarketListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder listItemView = null;//from www . jav a 2 s .c om if (convertView == null) { convertView = listContainer.inflate(this.itemViewResource, null, false); listItemView = new ViewHolder(); listItemView.content = (TextView) convertView.findViewById(R.id.marketList_title); listItemView.priceTextView = (TextView) convertView.findViewById(R.id.marketList_price); listItemView.username = (TextView) convertView.findViewById(R.id.marketList_username); listItemView.imageView = (ImageView) convertView.findViewById(R.id.marketList_img); listItemView.linearLayout = (LinearLayout) convertView.findViewById(R.id.nearby); listItemView.likeButton = (LinearLayout) convertView.findViewById(R.id.item_goods_like); listItemView.likeCount = (TextView) convertView.findViewById(R.id.item_goods_like_text); listItemView.viewCount = (TextView) convertView.findViewById(R.id.item_goods_viewcount); listItemView.likeImageButton = (ImageButton) convertView.findViewById(R.id.item_goods_like_btn); if (type == 1) { listItemView.username.setVisibility(View.GONE); listItemView.linearLayout.setVisibility(View.VISIBLE); listItemView.schoolname = (TextView) convertView.findViewById(R.id.marketList_schoolname); listItemView.distance = (TextView) convertView.findViewById(R.id.marketList_distance); } convertView.setTag(listItemView); } else { listItemView = (ViewHolder) convertView.getTag(); } final GoodsEntity tmpGoodsEntity = listItems.get(position); listItemView.content.setText(tmpGoodsEntity.getGoodTitle()); listItemView.priceTextView.setText("" + tmpGoodsEntity.getGoodPrice()); listItemView.username.setText(tmpGoodsEntity.getUserName()); if (type == 1) { listItemView.schoolname.setText("?[" + tmpGoodsEntity.getSchoolName() + "]"); listItemView.distance.setText(tmpGoodsEntity.getDistance() + "Km"); } if (tmpGoodsEntity.isLike()) { listItemView.likeImageButton.setBackgroundResource(R.drawable.liked); } listItemView.likeCount.setText(tmpGoodsEntity.getLikeCount() + ""); listItemView.viewCount.setText(tmpGoodsEntity.getViewCount() + ""); listItemView.likeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (MyApplication.userInfo == null) { Toast.makeText(context, context.getResources().getString(R.string.has_no_login), Toast.LENGTH_SHORT).show(); return; } ImageButton imageButton = (ImageButton) view.findViewById(R.id.item_goods_like_btn); TextView likeCount = (TextView) view.findViewById(R.id.item_goods_like_text); if (tmpGoodsEntity.isLike()) { postData(tmpGoodsEntity.getId(), "delete"); tmpGoodsEntity.setLike(false); imageButton.setBackgroundResource(R.drawable.like); String textString = likeCount.getText().toString(); if (textString != null) { likeCount.setText(Integer.parseInt(textString) - 1 + ""); } } else { postData(tmpGoodsEntity.getId(), "add"); tmpGoodsEntity.setLike(true); imageButton.setBackgroundResource(R.drawable.liked); String textString = likeCount.getText().toString(); if (textString != null) { likeCount.setText(Integer.parseInt(textString) + 1 + ""); } } } }); if (tmpGoodsEntity.getGoodImages() != null) { Picasso picasso = Picasso.with(listItemView.imageView.getContext()); picasso.load(CommonUtils.getFirstImg(tmpGoodsEntity.getGoodImages())) .placeholder(R.drawable.ic_img_loading).into(listItemView.imageView); } else { listItemView.imageView.setBackgroundResource(R.drawable.ic_img_loading); } return convertView; }
From source file:com.charon.materialsample.view.ScrollingTabs.java
/** * Add tab view./* ww w . ja v a 2 s . c o m*/ */ private void initTabView() { int totalWidth = 0; if (mViewPager != null && mTabAdapter != null) { mContainer.removeAllViews(); if (mEqualWidth) { for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) { View tab = mTabAdapter.getView(i); measureView(tab); totalWidth += tab.getWidth(); if (tab.getLayoutParams() != null) { // int width = tab.getLayoutParams().width; // int height = tab.getLayoutParams().height; } else { tab.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 100f)); } if (mTabAdapter.getSeparator() != null && i != mViewPager.getAdapter().getCount() - 1) { isUseSeperator = true; measureView(mTabAdapter.getSeparator()); totalWidth += mTabAdapter.getSeparator().getWidth(); } } if (totalWidth < mWindowWidth) { int count = mViewPager.getAdapter().getCount(); if (isUseSeperator) { tabWidth = (mWindowWidth - (count - 1) * mTabAdapter.getSeparator().getWidth()) / count; } else { tabWidth = mWindowWidth / count; } } } for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) { final View tab = mTabAdapter.getView(i); tab.setTag(i); if (tabWidth != 0) { mContainer.addView(tab, new LinearLayout.LayoutParams(tabWidth, LinearLayout.LayoutParams.MATCH_PARENT)); } else { mContainer.addView(tab, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 100f)); } // Segmentation view if (mTabAdapter.getSeparator() != null && i != mViewPager.getAdapter().getCount() - 1) { isUseSeperator = true; mContainer.addView(mTabAdapter.getSeparator()); } // Set click listener on tab. tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int index = (Integer) tab.getTag(); if (mTabClickListener != null) { mTabClickListener.onClick(index); } else { if (mViewPager.getCurrentItem() == index) { selectTab(index); } else { // If ViewPager change the page, the listener // will call selectTab method mViewPager.setCurrentItem(index, true); } } } }); } // Set the current selected tab when first coming. selectTab(mViewPager.getCurrentItem()); } }
From source file:com.charon.scrollingtabs.view.ScrollingTabs.java
/** * Add tab view./*from ww w . j ava2 s . c o m*/ */ private void initTabView() { int totalWidth = 0; if (mViewPager != null && mTabAdapter != null) { mContainer.removeAllViews(); if (mEqualWidth) { for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) { View tab = mTabAdapter.getView(i); measureView(tab); totalWidth += tab.getWidth(); if (tab.getLayoutParams() != null) { // int width = tab.getLayoutParams().width; // int height = tab.getLayoutParams().height; } else { tab.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 100f)); } if (mTabAdapter.getSeparator() != null && i != mViewPager.getAdapter().getCount() - 1) { isUseSeperator = true; measureView(mTabAdapter.getSeparator()); totalWidth += mTabAdapter.getSeparator().getWidth(); } } if (totalWidth < mWindowWidth) { int count = mViewPager.getAdapter().getCount(); if (isUseSeperator) { tabWidth = (mWindowWidth - (count - 1) * mTabAdapter.getSeparator().getWidth()) / count; } else { tabWidth = mWindowWidth / count; } } } for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) { final View tab = mTabAdapter.getView(i); tab.setTag(i); if (tabWidth != 0) { mContainer.addView(tab, new LinearLayout.LayoutParams(tabWidth, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); } else { mContainer.addView(tab, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 100f)); } // Segmentation view if (mTabAdapter.getSeparator() != null && i != mViewPager.getAdapter().getCount() - 1) { isUseSeperator = true; mContainer.addView(mTabAdapter.getSeparator()); } // Set click listener on tab. tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int index = (Integer) tab.getTag(); if (mTabClickListener != null) { mTabClickListener.onClick(index); } else { if (mViewPager.getCurrentItem() == index) { selectTab(index); } else { // If ViewPager change the page, the listener // will call selectTab method mViewPager.setCurrentItem(index, true); } } } }); } // Set the current selected tab when first coming. selectTab(mViewPager.getCurrentItem()); } }
From source file:com.fastbootmobile.encore.app.adapters.SearchAdapter.java
/** * {@inheritDoc}/*from w w w. j a v a 2s . co m*/ */ @Override public View getChildView(int i, int i2, boolean b, View root, ViewGroup parent) { final Context ctx = parent.getContext(); assert ctx != null; if (root == null) { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); root = inflater.inflate(R.layout.item_search_element, parent, false); ViewHolder holder = new ViewHolder(); holder.albumArtImageView = (AlbumArtImageView) root.findViewById(R.id.ivCover); holder.tvTitle = (TextView) root.findViewById(R.id.tvTitle); holder.tvSubtitle = (TextView) root.findViewById(R.id.tvSubTitle); holder.divider = (TextView) root.findViewById(R.id.divider); holder.ivSource = (ImageView) root.findViewById(R.id.ivSource); holder.ivOverflow = (ImageView) root.findViewById(R.id.ivOverflow); holder.vRoot = root; holder.ivOverflow.setTag(holder); root.setTag(holder); } final ViewHolder tag = (ViewHolder) root.getTag(); if (i2 == getChildrenCount(i) - 1) { tag.albumArtImageView.setVisibility(View.INVISIBLE); tag.ivSource.setVisibility(View.GONE); if (getChildrenCount(i) == 1) { tag.tvTitle.setText(R.string.search_no_results); } else { tag.tvTitle.setText(R.string.more); } tag.tvSubtitle.setText(null); tag.ivOverflow.setVisibility(View.GONE); tag.content = null; } else { tag.albumArtImageView.setVisibility(View.VISIBLE); tag.ivSource.setVisibility(View.VISIBLE); tag.ivOverflow.setVisibility(View.VISIBLE); switch (i) { case ARTIST: updateArtistTag(i2, tag); break; case ALBUM: updateAlbumTag(i2, tag); break; case SONG: updateSongTag(i2, tag); break; case PLAYLIST: updatePlaylistTag(i2, tag); break; default: Log.e(TAG, "Unknown group " + i); break; } } return root; }
From source file:net.phase.wallet.Currency.java
@Override public View getView(int position, View convertView, ViewGroup parent) { double exchrate = Currency.getRate(context.getActiveCurrency()); LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.walletlayout, null); v.setLongClickable(true);/*from w w w.j a v a 2s.c o m*/ v.setOnClickListener(context); v.setTag(position); DecimalFormat df = new DecimalFormat(WalletActivity.decimalString(decimalpoints)); TextView balanceTextView = (TextView) v.findViewById(R.id.walletBalanceText); balanceTextView.setText(df.format(wallets[position].balance / BalanceRetriever.SATOSHIS_PER_BITCOIN)); TextView curTextView = (TextView) v.findViewById(R.id.walletCurText); curTextView.setTextSize(10); if (exchrate != 0) { curTextView.setText( "(" + df.format(wallets[position].balance * exchrate / BalanceRetriever.SATOSHIS_PER_BITCOIN) + context.getActiveCurrency() + ")"); } else { curTextView.setText(""); } balanceTextView.setTextSize(20); balanceTextView.setTextColor(Color.GREEN); TextView nameTextView = (TextView) v.findViewById(R.id.walletNameText); nameTextView.setText(wallets[position].name); nameTextView.setTextColor(Color.BLACK); nameTextView.setTextSize(16); TextView lastUpdatedTextView = (TextView) v.findViewById(R.id.lastUpdatedText); lastUpdatedTextView.setTextColor(Color.GRAY); lastUpdatedTextView.setTextSize(8); lastUpdatedTextView.setText("Last Updated: " + getTimeStampString(wallets[position].lastUpdated)); TextView infoTextView = (TextView) v.findViewById(R.id.infoText); infoTextView.setTextColor(Color.GRAY); infoTextView.setTextSize(8); infoTextView.setText( wallets[position].keys.length + " keys (" + wallets[position].getActiveKeyCount() + " in use)"); TextView txLastUpdatedTextView = (TextView) v.findViewById(R.id.txLastUpdatedText); txLastUpdatedTextView.setTextColor(Color.GRAY); txLastUpdatedTextView.setTextSize(8); TextView txInfoTextView = (TextView) v.findViewById(R.id.txInfoText); txInfoTextView.setTextColor(Color.GRAY); txInfoTextView.setTextSize(8); if (wallets[position].transactions != null && wallets[position].transactions.length > 0) { txLastUpdatedTextView.setText( "Last Transaction: " + getTimeStampString(Transaction.latest(wallets[position].transactions))); txInfoTextView.setText(wallets[position].transactions.length + " transactions (" + Transaction.compressTransactions(wallets[position].transactions).length + " unique)"); } else { txLastUpdatedTextView.setText(""); txInfoTextView.setText(""); } Button button = (Button) v.findViewById(R.id.updateButton); button.setTag(position); button.setOnClickListener(context); return v; }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { Transfer item = getGroupItem(groupPosition); if (convertView == null || convertView instanceof TextView) { // convertView could be a dummy view due to an issue with the slide menu layout request order try {//w ww .j a va 2s . com convertView = View.inflate(context.get(), R.layout.view_transfer_list_item, null); } catch (Throwable e) { // creating a dummy view to avoid a force close due to a NPE // next time the "if" will try to recover the actual layout convertView = new TextView(context.get()); ((TextView) convertView).setText("Rendering error"); } } try { boolean clickable = item.getItems().size() == 0; convertView.setOnClickListener(clickable ? viewOnClickListener : null); convertView.setOnLongClickListener(clickable ? viewOnLongClickListener : null); convertView.setClickable(clickable); convertView.setLongClickable(clickable); setupGroupIndicator(convertView, isExpanded, item); convertView.setTag(item); populateGroupView(convertView, item); } catch (Throwable e) { Log.e(TAG, "Fatal error getting the group view: " + e.getMessage(), e); } return convertView; }
From source file:com.github.irshulx.Components.InputExtensions.java
public TextView insertEditText(int position, String hint, CharSequence text) { String nextHint = isLastText(position) ? null : editorCore.getPlaceHolder(); if (editorCore.getRenderType() == RenderType.Editor) { /**// ww w.ja v a2s . c o m * when user press enter from first line without keyin anything, need to remove the placeholder from that line 0... */ if (position == 1) { View view = editorCore.getParentView().getChildAt(0); EditorType type = editorCore.getControlType(view); if (type == EditorType.INPUT) { TextView textView = (TextView) view; if (TextUtils.isEmpty(textView.getText())) { textView.setHint(null); } } } final CustomEditText view = getNewEditTextInst(nextHint, text); editorCore.getParentView().addView(view, position); editorCore.setActiveView(view); final android.os.Handler handler = new android.os.Handler(); handler.postDelayed(new Runnable() { @Override public void run() { setFocus(view); } }, 0); editorCore.setActiveView(view); return view; } else { final TextView view = getNewTextView(text); view.setTag(editorCore.createTag(EditorType.INPUT)); editorCore.getParentView().addView(view); return view; } }
From source file:cl.smartcities.isci.transportinspector.adapters.dialogAdapters.BusSelectionAdapter.java
public View getView(final int position, View convertView, final ViewGroup parent) { final ViewHolder holder; /* set view */ if (convertView == null) { convertView = inflater.inflate(R.layout.bus_selection_dialog_bus_row, parent, false); holder = new ViewHolder(); /* initialize holder */ holder.busRoute = (TextView) convertView.findViewById(R.id.bus_route); holder.licensePlate1 = (TextView) convertView.findViewById(R.id.license_plate_1); holder.licencePlate2 = (TextView) convertView.findViewById(R.id.license_plate_2); holder.doNotKnowIcon = (TextView) convertView.findViewById(R.id.do_not_know_icon); holder.doNotKnow = (LinearLayout) convertView.findViewById(R.id.do_not_know_layout); holder.busImage = (ImageView) convertView.findViewById(R.id.bus_image); holder.dropDownButton = (ImageButton) convertView.findViewById(R.id.button); holder.platesLayout = convertView.findViewById(R.id.bus_options); holder.headerLayout = convertView.findViewById(R.id.route_info); /* get and set typefaces */ Typeface iconFont = Typeface.createFromAsset(this.getContext().getAssets(), this.getContext().getString(R.string.icon_font)); Typeface robotoBold = Typeface.createFromAsset(this.getContext().getAssets(), this.getContext().getString(R.string.roboto_bold_font)); holder.doNotKnowIcon.setTypeface(iconFont); holder.setHolderTypefaceBold(robotoBold); holder.position = position;/*from www . j a va 2 s . c o m*/ convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); if (activeHolder != null && holder.position == activeHolder.position) { activeHolder = null; } } holder.platesLayout.setVisibility(View.GONE); setUpNormalRow(holder, position); setBackgroundColor(holder, position); return convertView; }
From source file:com.activiti.android.ui.fragments.task.TaskDetailsFoundationFragment.java
private void displayPeopleSection(List<LightUserRepresentation> people) { show(R.id.task_details_people_card); if (people.isEmpty() || isEnded) { hide(R.id.task_details_people_card); return;//from w w w . ja v a 2 s.co m } // USER INVOLVED LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout userContainer = (LinearLayout) viewById(R.id.task_details_people_container); userContainer.removeAllViews(); View v; if (people == null || people.isEmpty()) { v = inflater.inflate(R.layout.row_single_line, userContainer, false); ((TextView) v.findViewById(R.id.toptext)).setText(R.string.task_message_no_people_involved); v.findViewById(R.id.icon).setVisibility(View.GONE); userContainer.addView(v); } else { TwoLinesViewHolder vh; for (LightUserRepresentation user : people) { v = inflater.inflate(R.layout.row_two_lines_swipe, userContainer, false); v.setTag(user.getId()); String fullName = user.getFullname(); vh = HolderUtils.configure(v, fullName != null && !fullName.isEmpty() ? fullName : user.getEmail(), null, R.drawable.ic_account_circle_grey); if (picasso != null) { picasso.cancelRequest(vh.icon); picasso.load(getAPI().getUserGroupService().getPicture(user.getId())) .placeholder(R.drawable.ic_account_circle_grey).fit().transform(roundedTransformation) .into(vh.icon); } SwipeLayout swipeLayout = (SwipeLayout) v.findViewById(R.id.swipe_layout); swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown); swipeLayout.setDragEdge(SwipeLayout.DragEdge.Right); LinearLayout actions = (LinearLayout) swipeLayout.findViewById(R.id.bottom_wrapper); ImageButton action = (ImageButton) inflater.inflate(R.layout.form_swipe_action_, (LinearLayout) swipeLayout.findViewById(R.id.bottom_wrapper), false); action.setImageResource(R.drawable.ic_remove_circle_outline_white); action.setTag(user); action.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { removeInvolved(((LightUserRepresentation) v.getTag()), new InvolveTaskRepresentation(((LightUserRepresentation) v.getTag()).getId())); } }); actions.addView(action); userContainer.addView(v); } } if (!isEnded) { v = inflater.inflate(R.layout.footer_two_buttons_borderless, userContainer, false); Button b = (Button) v.findViewById(R.id.button_action_left); b.setVisibility(View.GONE); b = (Button) v.findViewById(R.id.button_action_right); b.setText(R.string.task_action_involve); b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startInvolveAction(); } }); userContainer.addView(v); } }