public void setToolbar(Object params) { toolBar.setBackgroundColor(Color.GRAY); toolBar.removeAllViews(); setupToolbar(toolBar, params); toolBar.requestLayout(); view.requestLayout(); }
private void resetSeekBars() { LinearLayout lo = (LinearLayout) findViewById(R.id.modAttributesLayout); lo.removeAllViews(); AttributeReducer reducer = new AttributeReducer(this); reducer.addOnAttributeChangedListener(this); reducer.addAttributes(investigator.getAgeModifiableAttribute()); lo.addView(reducer); lo.requestLayout(); }
private void findViews() { classifyLayout = (View) findViewById(R.id.classifyLayout); messengerListView = (ListView) findViewById(R.id.msgListView); contactPersonListView = (ListView) findViewById(R.id.favoriteContactPersonListView); rightArrowImageView = (ImageView) findViewById(R.id.classifySmsImageView); rightArrowImageView.setOnClickListener(this); // tabControlImageView = (ImageView) findViewById(R.id.tabControlImageView); // tabControlImageView.setOnClickListener(this); dialogListLayout = (LinearLayout) messengerListView.getParent(); tabContainerLayout = (LinearLayout) findViewById(R.id.tabContainerLayout); smsTabTitleTextView = (TextView) findViewById(R.id.smsTabTitleTextView); smsTabTitleTextView.setOnClickListener(this); // set linearlayout params DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); int mScreenWidth = metric.widthPixels; dialogListLayout.setLayoutParams(new LayoutParams(mScreenWidth, LayoutParams.FILL_PARENT)); dialogListLayout.setBackgroundResource(R.color.bg_color); dialogListLayout.requestLayout(); }
public void removeToolbar() { toolBar.removeAllViews(); toolBar.requestLayout(); view.requestLayout(); }
@SuppressWarnings("unchecked") private void setupToolbar(LinearLayout tool_bar, Object params) { Context ctx = RhodesActivity.getContext(); mCustomBackgroundColorEnable = false; Vector<Object> buttons = null; if (params != null) { if (params instanceof Vector<?>) { buttons = (Vector<Object>) params; } else if (params instanceof Map<?, ?>) { Map<Object, Object> settings = (Map<Object, Object>) params; Object colorObj = settings.get("color"); if (colorObj != null && (colorObj instanceof Map<?, ?>)) { Map<Object, Object> color = (Map<Object, Object>) colorObj; Object redObj = color.get("red"); Object greenObj = color.get("green"); Object blueObj = color.get("blue"); if (redObj != null && greenObj != null && blueObj != null && (redObj instanceof String) && (greenObj instanceof String) && (blueObj instanceof String)) { try { int red = Integer.parseInt((String) redObj); int green = Integer.parseInt((String) greenObj); int blue = Integer.parseInt((String) blueObj); mCustomBackgroundColor = ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | ((blue & 0xFF)) | 0xFF000000; mCustomBackgroundColorEnable = true; tool_bar.setBackgroundColor(Color.rgb(red, green, blue)); } catch (NumberFormatException e) { // Do nothing here } } } Object bkgObj = settings.get("background_color"); if ((bkgObj != null) && (bkgObj instanceof String)) { int color = Integer.decode(((String) bkgObj)).intValue(); int red = (color & 0xFF0000) >> 16; int green = (color & 0xFF00) >> 8; int blue = (color & 0xFF); tool_bar.setBackgroundColor(Color.rgb(red, green, blue)); mCustomBackgroundColor = color | 0xFF000000; mCustomBackgroundColorEnable = true; } Object buttonsObj = settings.get("buttons"); if (buttonsObj != null && (buttonsObj instanceof Vector<?>)) buttons = (Vector<Object>) buttonsObj; } } if (params != null) { LinearLayout group = null; // First group should have gravity LEFT int gravity = Gravity.LEFT; for (int i = 0, lim = buttons.size(); i < lim; ++i) { Object param = buttons.elementAt(i); if (!(param instanceof Map<?, ?>)) throw new IllegalArgumentException("Hash expected"); Map<Object, Object> hash = (Map<Object, Object>) param; View button = createButton(hash); if (button == null) { group = null; gravity = Gravity.CENTER; continue; } button.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); if (group == null) { group = new LinearLayout(ctx); group.setGravity(gravity); group.setOrientation(LinearLayout.HORIZONTAL); group.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, FILL_PARENT, 1)); tool_bar.addView(group); } group.addView(button); } // Last group should have gravity RIGHT if (group != null) { group.setGravity(Gravity.RIGHT); tool_bar.requestLayout(); } } }
@Override public void handleMessage(Message msg) { switch (msg.what) { case GlobalParam.SHOW_SCROLLREFRESH: if (mIsRefreshing) { mScrollContainer.onRefreshComplete(); break; } mIsRefreshing = true; getPublishWeiboData(GlobalParam.LIST_LOAD_REFERSH); break; case GlobalParam.HIDE_SCROLLREFRESH: mIsRefreshing = false; mScrollContainer.onRefreshComplete(); for (int i = 0; i < mColumnCount; i++) { clearMap(mPinMark[i]); } clearArray(mColumnHeight, true); clearMap(mIViews); clearMap(mPins); clearArray(mLineIndex, false); clearArray(mBottomIndex, false); clearArray(mTopIndex, true); if (mWaterFallContainer != null) { for (int i = 0; i < mWaterFallContainer.getChildCount(); i++) { if (mWaterFallContainer.getChildAt(i) != null) { LinearLayout linearLayout = (LinearLayout) mWaterFallContainer.getChildAt(i); linearLayout.removeAllViews(); } } mWaterFallContainer.requestLayout(); } AddItemToContainer(0); if (mPicList != null && mPicList.size() > 0) { mCount = mPicList.size(); } break; case GlobalParam.HIDE_PROGRESS_DIALOG: if (isLoadMore) { isLoadMore = false; if (mCount < mPicList.size()) { AddItemToContainer(mCount); } } else { InitLayout(); } if (mPicList != null && mPicList.size() > 0) { mCount = mPicList.size(); } hideProgressDialog(); break; case GlobalParam.MSG_NETWORK_ERROR: hideProgressDialog(); if (mIsRefreshing) { mIsRefreshing = false; mScrollContainer.onRefreshComplete(); } Toast.makeText(mContext, R.string.network_error, Toast.LENGTH_LONG).show(); break; default: break; } }
/** * Creates a new ListView component. * * @param container container that the component will be placed in */ public ListView(ComponentContainer container) { super(container); this.container = container; items = YailList.makeEmptyList(); // initialize selectionIndex which also sets selection SelectionIndex(0); view = new android.widget.ListView(container.$context()); view.setOnItemClickListener(this); view.setChoiceMode(android.widget.ListView.CHOICE_MODE_SINGLE); view.setScrollingCacheEnabled(false); listViewLayout = new LinearLayout(container.$context()); listViewLayout.setOrientation(LinearLayout.VERTICAL); txtSearchBox = new EditText(container.$context()); txtSearchBox.setSingleLine(true); txtSearchBox.setWidth(Component.LENGTH_FILL_PARENT); txtSearchBox.setPadding(10, 10, 10, 10); txtSearchBox.setHint("Search list..."); // set up the listener txtSearchBox.addTextChangedListener( new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text adapter.getFilter().filter(cs); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // no-op. Required method } @Override public void afterTextChanged(Editable arg0) { // no-op. Required method } }); if (showFilter) { txtSearchBox.setVisibility(View.VISIBLE); } else { txtSearchBox.setVisibility(View.GONE); } // set the colors and initialize the elements // note that the TextColor and ElementsFromString setters // need to have the textColor set first, since they reset the // adapter Width(Component.LENGTH_FILL_PARENT); BackgroundColor(DEFAULT_BACKGROUND_COLOR); SelectionColor(DEFAULT_SELECTION_COLOR); textColor = DEFAULT_TEXT_COLOR; TextColor(textColor); textSize = DEFAULT_TEXT_SIZE; TextSize(textSize); ElementsFromString(""); listViewLayout.addView(txtSearchBox); listViewLayout.addView(view); listViewLayout.requestLayout(); container.$add(this); };