List of usage examples for android.view View setId
public void setId(@IdRes int id)
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragmentProduct.java
/** * * @param inflater/*from w w w . j a v a2 s .c o m*/ * @param container * @param savedInstanceState * @return */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.dagvergunning_fragment_product, container, false); // bind the elements to the view ButterKnife.bind(this, view); // get the producten from the sharedprefs and create the product selectors SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext()); String producten = settings .getString(getContext().getString(R.string.sharedpreferences_key_markt_producten), null); if (producten != null) { // split comma-separated string into list with product strings List<String> productList = Arrays.asList(producten.split(",")); if (productList.size() > 0) { String[] productKeys = getResources().getStringArray(R.array.array_product_key); String[] productTypes = getResources().getStringArray(R.array.array_product_type); String[] productTitles = getResources().getStringArray(R.array.array_product_title); // inflate the producten placeholder view LinearLayout placeholderLayout = (LinearLayout) view.findViewById(R.id.producten_placeholder); if (placeholderLayout != null) { placeholderLayout.removeAllViews(); LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // add multiple product item views to the placeholder view for (int i = 0; i < productList.size(); i++) { // get a resource id for the product int id = Utility.getResId("product_" + productList.get(i), R.id.class); if (id != -1) { // get the corresponding product type based on the productlist item value String productType = ""; for (int j = 0; j < productKeys.length; j++) { if (productKeys[j].equals(productList.get(i))) { productType = productTypes[j]; } } // get the product item layout depending on the product type View childLayout = null; if (productType.equals("integer")) { childLayout = layoutInflater.inflate(R.layout.dagvergunning_product_item_count, null); } else if (productType.equals("boolean")) { childLayout = layoutInflater.inflate(R.layout.dagvergunning_product_item_toggle, null); } if (childLayout != null) { childLayout.setId(id); // get the corresponding product title based on the productlist item value String productTitle = ""; for (int j = 0; j < productKeys.length; j++) { if (productKeys[j].equals(productList.get(i))) { productTitle = productTitles[j]; } } // set product name TextView productNameText = (TextView) childLayout.findViewById(R.id.product_name); productNameText.setText(productTitle); // if product type is integer add click handlers to +- buttons if (productType.equals("integer")) { // set onclickhandler on the - buttons to decrease the value of the product_count textview Button countDownButton = (Button) childLayout .findViewById(R.id.product_count_down); countDownButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { changeProductCountText(v, false); } }); // set onclickhandler on the + buttons to increase the value of the product_count textview Button countUpButton = (Button) childLayout.findViewById(R.id.product_count_up); countUpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { changeProductCountText(v, true); } }); } // add view and move cursor to next product placeholderLayout.addView(childLayout, i); } } } } } } return view; }
From source file:com.nqsky.nest.home.activity.RecyclerGridFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final RecyclerListAdapter adapter = new RecyclerListAdapter(getActivity(), this) { View view;/* ww w.jav a2s . c om*/ @Override public ItemViewHolder onCreatViewFristVHoleder(ViewGroup parent, int viewType) { view = new WebView(getActivity()); view.setId(R.id.webview); GridLayoutManager.LayoutParams params = new GridLayoutManager.LayoutParams( GridLayoutManager.LayoutParams.MATCH_PARENT, 800); view.setLayoutParams(params); return new AppItemViewHolder(view, viewType); } @Override public ItemViewHolder onCreatViewItemVHoleder(ViewGroup parent, int viewType) { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main, null, false); return new AppItemViewHolder(view, viewType); } @Override public ItemViewHolder onCreatViewHeaderVHoleder(ViewGroup parent, int viewType) { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header, parent, false); return new AppItemViewHolder(view, viewType); } @Override public void onBindViewFristHolder(ItemViewHolder holder, int position) { if (holder instanceof AppItemViewHolder) { ((AppItemViewHolder) holder).webview.loadUrl("http://www.qq.com");//.setText(super.mItems.get(position).getText()); } } @Override public void onBindViewItemHolder(ItemViewHolder holder, int position) { if (holder instanceof AppItemViewHolder) { ((AppItemViewHolder) holder).textView.setText(super.mItems.get(position).getText()); ((AppItemViewHolder) holder).handleView .setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.ic_app)); } } @Override public void onBindViewHeaderHolder(ItemViewHolder holder, int position) { if (holder instanceof AppItemViewHolder) { ((AppItemViewHolder) holder).textView.setText(super.mItems.get(position).getText()); } } }; RecyclerView recyclerView = (RecyclerView) view.findViewById(android.R.id.list); recyclerView.setHasFixedSize(true); recyclerView.setAdapter(adapter); recyclerView.setItemAnimator(new DefaultItemAnimator()); // final int spanCount = getResources().getInteger(R.integer.grid_columns); final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 4); recyclerView.setLayoutManager(layoutManager); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { switch (adapter.getItemViewType(position)) { case RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER: return 4; case RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER: return 4; case RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM: return 1; default: return 4; } } }); ItemTouchHelper.Callback callback = new CJTouchHelperCallback(adapter); mItemTouchHelper = new ItemTouchHelper(callback); mItemTouchHelper.attachToRecyclerView(recyclerView); adapter.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(RecyclerGridFragment.this.getActivity(), "?" + position + "", Toast.LENGTH_SHORT).show(); if (adapter.getItemViewType(position) == RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM) { try { ItemBean bean = new ItemBean(); bean.setText("?" + position + ""); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setId(position / 10 + ""); bean.setpID(adapter.getItemBean(position).getpID()); adapter.addItem(adapter.getItemBean(position).getpID(), bean); } catch (NullPointerException e) { e.printStackTrace(); } } else { adapter.delItem(position + 1); } } }); ItemBean bean; List<ItemBean> list = new ArrayList<ItemBean>(); for (int i = 0; i < 80; i++) { bean = new ItemBean(); if (i % 10 == 0) { bean.setText("" + i / 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER); bean.setId(String.valueOf((i / 10))); } else { bean.setText("Item" + i / 10 + i % 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setpID(String.valueOf((i / 10))); bean.setId(String.valueOf((i))); } list.add(bean); } bean = new ItemBean(); bean.setText(""); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER); bean.setId(String.valueOf((10))); list.add(0, bean); adapter.addItems(list); final com.cjj.MaterialRefreshLayout swipeRefreshLayout; final Handler handler = new Handler(); swipeRefreshLayout = (com.cjj.MaterialRefreshLayout) view.findViewById(R.id.swipe_refresh_widget); swipeRefreshLayout.setWaveColor(0xf90fffff); swipeRefreshLayout.setIsOverLay(true); swipeRefreshLayout.setWaveShow(true); swipeRefreshLayout.setLoadMore(true); swipeRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() { @Override public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) { handler.postDelayed(new Runnable() { @Override public void run() { adapter.clear(); ItemBean bean; List<ItemBean> list = new ArrayList<ItemBean>(); for (int i = 0; i < 80; i++) { bean = new ItemBean(); if (i % 10 == 0) { bean.setText("" + i / 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER); bean.setId(String.valueOf((i / 10))); } else { bean.setText("" + i / 10 + i % 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setpID(String.valueOf((i / 10))); bean.setId(String.valueOf((i))); } list.add(bean); } bean = new ItemBean(); bean.setText(""); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER); bean.setId(String.valueOf((10))); list.add(0, bean); adapter.addItems(list); materialRefreshLayout.finishRefresh(); } }, 1000); } @Override public void onRefreshLoadMore(final MaterialRefreshLayout materialRefreshLayout) { super.onRefreshLoadMore(materialRefreshLayout); handler.postDelayed(new Runnable() { @Override public void run() { ArrayList list = new ArrayList<ItemBean>(); for (int i = 60; i < 90; i++) { ItemBean bean = new ItemBean(); if (i % 10 == 0) { bean.setText("" + i / 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_HEADER); bean.setId(String.valueOf((i / 10))); } else { bean.setText("" + i / 10 + i % 10); bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_ITEM); bean.setpID(String.valueOf((i / 10))); bean.setId(String.valueOf((i))); } list.add(bean); } // bean=new ItemBean(); // bean.setText("" ); // bean.setType(RecyclerListAdapter.ITEM_VIEW_TYPE_CUSTOMER); // bean.setId(String.valueOf((10))); // list.add(0,bean); adapter.addItems(list); materialRefreshLayout.finishRefreshLoadMore(); } }, 1000); } }); }
From source file:com.nextgis.maplibui.dialog.LocalResourcesListAdapter.java
@Override public View getView(int i, View view, ViewGroup viewGroup) { View v = view; final File file = (File) getItem(i); int viewId;/* www .j ava 2 s . c om*/ if (null == file) { if (null == v || v.getId() != R.id.resourcegroup_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_resourcegroup, null); v.setId(R.id.resourcegroup_row); ImageView ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_folder)); } TextView tvText = (TextView) v.findViewById(R.id.tvName); tvText.setText(mContext.getString(R.string.up_dots)); TextView tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.up)); } else { ImageView ivIcon; TextView tvDesc; CheckBox checkBox; RadioButton radioButton; LayoutInflater inflater = LayoutInflater.from(mContext); switch (getFileType(file)) { case FILETYPE_FOLDER: if (0 == (mTypeMask & FILETYPE_FOLDER) || (mCanWrite && !FileUtil.isDirectoryWritable(file))) { if (v == null || v.getId() != R.id.resourcegroup_row) { v = inflater.inflate(R.layout.row_resourcegroup, null); v.setId(R.id.resourcegroup_row); } } else { if (mCanSelectMulti) //chow checkbox { viewId = R.id.resource_check_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_check, null); v.setId(viewId); } //add check listener checkBox = (CheckBox) v.findViewById(R.id.check); setCheckBox(checkBox, file); } else { viewId = R.id.resource_radio_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_radio, null); v.setId(viewId); } //add check listener radioButton = (RadioButton) v.findViewById(R.id.radio); setRadioButton(radioButton, file); } } ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_folder)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.folder)); break; case FILETYPE_ZIP: if (mCanSelectMulti) //chow checkbox { viewId = R.id.resource_check_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_check, null); v.setId(viewId); } //add check listener checkBox = (CheckBox) v.findViewById(R.id.check); setCheckBox(checkBox, file); } else { viewId = R.id.resource_radio_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_radio, null); v.setId(viewId); } //add check listener radioButton = (RadioButton) v.findViewById(R.id.radio); setRadioButton(radioButton, file); } ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_zip)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.zip)); break; case FILETYPE_FB: if (mCanSelectMulti) //chow checkbox { viewId = R.id.resource_check_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_check, null); v.setId(viewId); } //add check listener checkBox = (CheckBox) v.findViewById(R.id.check); setCheckBox(checkBox, file); } else { viewId = R.id.resource_radio_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_radio, null); v.setId(viewId); } //add check listener radioButton = (RadioButton) v.findViewById(R.id.radio); setRadioButton(radioButton, file); } ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_formbuilder)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.formbuilder)); break; case FILETYPE_GEOJSON: if (mCanSelectMulti) //chow checkbox { viewId = R.id.resource_check_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_check, null); v.setId(viewId); } //add check listener checkBox = (CheckBox) v.findViewById(R.id.check); setCheckBox(checkBox, file); } else { viewId = R.id.resource_radio_row; if (v == null || v.getId() != viewId) { v = inflater.inflate(R.layout.row_resource_radio, null); v.setId(viewId); } //add check listener radioButton = (RadioButton) v.findViewById(R.id.radio); setRadioButton(radioButton, file); } ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_geojson)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.geojson)); break; } TextView tvText = (TextView) v.findViewById(R.id.tvName); tvText.setText(file.getName()); } return v; }
From source file:com.nextgis.maplibui.dialog.NGWResourcesListAdapter.java
protected View getConnectionView(Connection connection, View view) { View v = view; if (null == connection) { //create add account button if (null == v || v.getId() != R.id.resourcegroup_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_resourcegroup, null); v.setId(R.id.resourcegroup_row); }//from w w w . ja va2 s. c o m ImageView ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_add_account)); TextView tvText = (TextView) v.findViewById(R.id.tvName); tvText.setText(mContext.getString(R.string.add_account)); } else { if (null == v || v.getId() != R.id.resourcegroup_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_resourcegroup, null); v.setId(R.id.resourcegroup_row); } ImageView ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_ngw)); TextView tvText = (TextView) v.findViewById(R.id.tvName); tvText.setText(connection.getName()); } TextView tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setVisibility(View.GONE); return v; }
From source file:org.digitalcampus.oppia.widgets.FeedbackWidget.java
@SuppressWarnings("unchecked") @Override//from w w w . ja v a 2 s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { prefs = PreferenceManager.getDefaultSharedPreferences(super.getActivity()); View vv = super.getLayoutInflater(savedInstanceState).inflate(R.layout.widget_quiz, null); this.container = container; course = (Course) getArguments().getSerializable(Course.TAG); activity = ((Activity) getArguments().getSerializable(Activity.TAG)); this.setIsBaseline(getArguments().getBoolean(CourseActivity.BASELINE_TAG)); feedbackContent = ((Activity) getArguments().getSerializable(Activity.TAG)) .getContents(prefs.getString(PrefsActivity.PREF_LANGUAGE, Locale.getDefault().getLanguage())); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); vv.setLayoutParams(lp); vv.setId(activity.getActId()); if ((savedInstanceState != null) && (savedInstanceState.getSerializable("widget_config") != null)) { setWidgetConfig((HashMap<String, Object>) savedInstanceState.getSerializable("widget_config")); } return vv; }
From source file:com.nextgis.maplibui.dialog.NGWResourcesListAdapter.java
protected View getResourceView(Resource resource, View view) { View v = view; TextView tvDesc;// w ww . j a v a 2s . c om if (null == resource) { //create up button if (null == v || v.getId() != R.id.resourcegroup_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_resourcegroup, null); v.setId(R.id.resourcegroup_row); ImageView ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_ngw_folder)); } TextView tvText = (TextView) v.findViewById(R.id.tvName); tvText.setText(mContext.getString(R.string.up_dots)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.up)); } else { ImageView ivIcon; CheckBox checkBox1 = null, checkBox2 = null; final int id = resource.getId(); int resourceType = resource.getType(); if (0 == (mTypeMask & resourceType) && resourceType != Connection.NGWResourceTypeResourceGroup) { if (null == v || v.getId() != R.id.empty_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_empty, null); v.setId(R.id.empty_row); } return v; } switch (resourceType) { case Connection.NGWResourceTypeResourceGroup: if (null == v || v.getId() != R.id.resourcegroup_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_resourcegroup, null); v.setId(R.id.resourcegroup_row); ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_ngw_folder)); } tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.resource_group)); break; case Connection.NGWResourceTypeRasterLayer: case Connection.NGWResourceTypeWMSClient: if (null == v || v.getId() != R.id.ngw_layer_check_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_ngwlayer_check, null); v.setId(R.id.ngw_layer_check_row); } ivIcon = (ImageView) v.findViewById(R.id.ivIcon); int icon = resourceType == Connection.NGWResourceTypeRasterLayer ? R.drawable.ic_raster : R.drawable.ic_ngw_wms_client; ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, icon)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.raster_layer)); //add check listener checkBox1 = (CheckBox) v.findViewById(R.id.checkBox1); setCheckBox(checkBox1, id, 1); break; case Connection.NGWResourceTypeVectorLayer: case Connection.NGWResourceTypePostgisLayer: LayerWithStyles layer = (LayerWithStyles) resource; if (layer.getStyleCount() > 0) { if (null == v || v.getId() != R.id.ngw_layer_doublecheck_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_ngwlayer_doublecheck, null); v.setId(R.id.ngw_layer_doublecheck_row); } //add check listener checkBox1 = (CheckBox) v.findViewById(R.id.checkBox1); setCheckBox(checkBox1, id, 1); checkBox2 = (CheckBox) v.findViewById(R.id.checkBox2); setCheckBox(checkBox2, id, 2); } else { if (null == v || v.getId() != R.id.ngw_layer_check_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_ngwlayer_check, null); v.setId(R.id.ngw_layer_check_row); } TextView tvType = (TextView) v.findViewById(R.id.type1); tvType.setText(mContext.getString(R.string.vector)); //add check listener checkBox1 = (CheckBox) v.findViewById(R.id.checkBox1); setCheckBox(checkBox1, id, 2); } int vectorIcon = resourceType == Connection.NGWResourceTypeVectorLayer ? R.drawable.ic_vector : R.drawable.ic_pg_vector; ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, vectorIcon)); int desc = resourceType == Connection.NGWResourceTypeVectorLayer ? R.string.vector_layer : R.string.pg_layer; tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(desc)); break; case Connection.NGWResourceTypeWebMap: if (null == v || v.getId() != R.id.ngw_layer_check_row) { LayoutInflater inflater = LayoutInflater.from(mContext); v = inflater.inflate(R.layout.row_ngwlayer_check, null); v.setId(R.id.ngw_layer_check_row); } ivIcon = (ImageView) v.findViewById(R.id.ivIcon); ivIcon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.ic_ngw_webmap)); tvDesc = (TextView) v.findViewById(R.id.tvDesc); tvDesc.setText(mContext.getString(R.string.web_map)); //add check listener checkBox1 = (CheckBox) v.findViewById(R.id.checkBox1); setCheckBox(checkBox1, id, 1); break; default: return null; } tvDesc.setVisibility(View.GONE); if (!mShowCheckboxes) { if (checkBox1 != null) v.findViewById(R.id.check_raster).setVisibility(View.GONE); if (checkBox2 != null) v.findViewById(R.id.check_vector).setVisibility(View.GONE); } TextView tvText = (TextView) v.findViewById(R.id.tvName); tvText.setText(resource.getName()); } return v; }
From source file:org.solovyev.android.messenger.BaseListFragment.java
@Nonnull private View createListView(@Nonnull Context context) { final View listView = new ListView(context); fillListView((ListView) listView, context); listView.setId(android.R.id.list); return listView; }
From source file:com.trimph.toprand.trimphrxandroid.trimph.ui.main.news.view.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);//from ww w . j a va 2 s.c om tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); if (onTabStripItemCickListener != null && currentPosition == position) { onTabStripItemCickListener.onTabStripItemCickListener(v, position); } } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tab.setId(position); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java
final void ensureSubDecor() { Log.d("simply", "mHasActionBar:" + mHasActionBar + ",mSubDecor:" + mSubDecorInstalled + ",mOverlayActionBar:" + mOverlayActionBar); Window window = mActivity.getWindow(); // Initializing the window decor can change window feature flags. // Make sure that we have the correct set before performing the test below. window.getDecorView();/*from ww w . j ava2 s .c o m*/ if (mHasActionBar && !mSubDecorInstalled) { //Add by Fan.Yang /* *//** * This needs some explanation. As we can not use the android:theme attribute * pre-L, we emulate it by manually creating a LayoutInflater using a * ContextThemeWrapper pointing to actionBarTheme. *//* TypedValue outValue = new TypedValue(); mActivity.getTheme().resolveAttribute(R.attr.actionBarTheme, outValue, true); Context themedContext; if (outValue.resourceId != 0) { themedContext = new ContextThemeWrapper(mActivity, outValue.resourceId); } else { themedContext = mActivity; }*/ if (mOverlayActionBar) { mActivity.superSetContentView(R.layout.abc_action_bar_decor_overlay); } else { mActivity.superSetContentView(R.layout.abc_action_bar_decor); } if (!isHome()) { mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); mActivity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); mActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); mActivity.getWindow().setStatusBarColor(Color.TRANSPARENT); mActivity.getWindow().setNavigationBarColor(Color.TRANSPARENT); } mActionBarView = (ActionBarView) mActivity.findViewById(R.id.action_bar); mActionBarView.setWindowCallback(mActivity); mActionModeView = (ActionBarContextView) mActivity.findViewById(R.id.action_context_bar); splitActionBarView = (LewaActionBarContainer) mActivity.findViewById(R.id.split_action_bar); if (splitActionBarView != null) { splitActionBarView.setOnActionMenuDoubleClickListener( new LewaActionBarContainer.OnActionMenuDoubleClickListener() { @Override public void onDoubleClick() { // TODO Auto-generated method stub Log.d(TAG, "===ActionMenuDouble==="); toggleActionMenuStyle(false); } }); splitActionBarView.setOnActionModeMenuDoubleClickListener( new LewaActionBarContainer.OnActionMenuDoubleClickListener() { @Override public void onDoubleClick() { // TODO Auto-generated method stub Log.d(TAG, "===ModeMenuDoubleClick==="); toggleActionMenuStyle(true); } }); splitActionBarView .setOnActionOptionMenuSlideListener(new LewaActionBarContainer.OnActionSlideListener() { public void onSlide(boolean isUp) { if (isUp) { splitActionBarView.setActionOptionMenuVisibility(true); } else { splitActionBarView.setActionOptionMenuVisibility(false); } } }); } /** * Progress Bars */ if (mFeatureProgress) { mActionBarView.initProgress(); } if (mFeatureIndeterminateProgress) { mActionBarView.initIndeterminateProgress(); } /** * Split Action Bar */ boolean splitWhenNarrow = UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW.equals(getUiOptionsFromMetadata()); boolean splitActionBar; if (splitWhenNarrow) { splitActionBar = mActivity.getResources().getBoolean(R.bool.abc_split_action_bar_is_narrow); } else { TypedArray a = mActivity.obtainStyledAttributes(R.styleable.Theme); // splitActionBar = a // .getBoolean(R.styleable.Theme_windowActionBar, false); splitActionBar = true; a.recycle(); } final ActionBarContainer splitView = (ActionBarContainer) mActivity.findViewById(R.id.split_action_bar); if (splitView != null) { mActionBarView.setSplitView(splitView); mActionBarView.setSplitActionBar(splitActionBar); mActionBarView.setSplitWhenNarrow(splitWhenNarrow); final ActionBarContextView cab = (ActionBarContextView) mActivity .findViewById(R.id.action_context_bar); cab.setSplitView(splitView); cab.setSplitActionBar(splitActionBar); cab.setSplitWhenNarrow(splitWhenNarrow); } // Change our content FrameLayout to use the android.R.id.content id. // Useful for fragments. View content = mActivity.findViewById(android.R.id.content); content.setId(View.NO_ID); View abcContent = mActivity.findViewById(R.id.action_bar_activity_content); abcContent.setId(android.R.id.content); // A title was set before we've install the decor so set it now. if (mTitleToSet != null) { mActionBarView.setWindowTitle(mTitleToSet); mTitleToSet = null; } mSubDecorInstalled = true; supportInvalidateOptionsMenu(); } }
From source file:com.geoffreybuttercrumbs.arewethereyet.DrawerFragment.java
private void recent() { LayoutInflater inflater = getActivity().getLayoutInflater(); SharedPreferences prefs = getActivity().getSharedPreferences("AreWeThereYet", Context.MODE_WORLD_WRITEABLE); for (int i = 1; i <= 5; i++) { Location location = new Location("POINT_LOCATION"); String address = prefs.getString(POINT_ADDRESS_KEY + i, ""); location.setLatitude(0);//from ww w. j a v a2s . c om location.setLongitude(0); if (prefs.contains(POINT_LATITUDE_KEY + i)) { location.setLatitude(prefs.getFloat(POINT_LATITUDE_KEY + i, 0)); } if (prefs.contains(POINT_LONGITUDE_KEY + i)) { location.setLongitude(prefs.getFloat(POINT_LONGITUDE_KEY + i, 0)); } LinearLayout RecentParent = (LinearLayout) V.findViewById(R.id.group_recent); View Recent = inflater.inflate(R.layout.saved_item, null); Recent.setOnClickListener(this); CharSequence name; if (!address.equals("")) { name = address; ((TextView) Recent.findViewById(R.id.savedLabel)).setTextColor(0xDDFFFFFF); ((CompoundButton) Recent.findViewById(R.id.saveCB)).setOnCheckedChangeListener(this); } else { name = "No Recent Alarms"; ((TextView) Recent.findViewById(R.id.savedLabel)).setTextColor(0xDD999999); Recent.findViewById(R.id.saveCB).setEnabled(false); } ((TextView) Recent.findViewById(R.id.savedLabel)).setText(name); ((TextView) Recent.findViewById(R.id.savedLabel)).setTextSize(14); Recent.findViewById(R.id.saveCB).setTag(i); Recent.setId(i); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); RecentParent.setLayoutParams(params); RecentParent.addView(Recent); } }