Example usage for android.widget TextView getId

List of usage examples for android.widget TextView getId

Introduction

In this page you can find the example usage for android.widget TextView getId.

Prototype

@IdRes
@ViewDebug.CapturedViewProperty
public int getId() 

Source Link

Document

Returns this view's identifier.

Usage

From source file:com.esri.arcgisruntime.sample.featurelayerupdateattributes.MainActivity.java

/**
 * Displays Callout//from   www. ja v a  2  s.  c om
 * @param title the text to show in the Callout
 */
private void showCallout(String title) {

    // create a text view for the callout
    RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext());

    TextView calloutContent = new TextView(getApplicationContext());
    calloutContent.setId(R.id.textview);
    calloutContent.setTextColor(Color.BLACK);
    calloutContent.setTextSize(18);
    calloutContent.setPadding(0, 10, 10, 0);

    calloutContent.setText(title);

    RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId());

    // create image view for the callout
    ImageView imageView = new ImageView(getApplicationContext());
    imageView.setImageDrawable(
            ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info_outline_black_18dp));
    imageView.setLayoutParams(relativeParams);
    imageView.setOnClickListener(new ImageViewOnclickListener());

    calloutLayout.addView(calloutContent);
    calloutLayout.addView(imageView);

    mCallout.setLocation(mMapView.screenToLocation(mClickPoint));
    mCallout.setContent(calloutLayout);
    mCallout.show();
}

From source file:in.silive.bo.sliding.SlidingTabLayout.java

private void populateTabStrip() {
    Log.d("Strips", "populate TabStrip");
    final PagerAdapter adapter = mViewPager.getAdapter();
    /* final OnClickListener tabClickListener = new TabClickListener();
    */ for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;/*from   w w w  .ja v a  2 s . com*/
        TextView tabTitleView = null;
        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
            //  tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
            setCustomTabView(tabView.getId(), tabTitleView.getId());
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }
        if (i == 0) {
            previousChild = tabTitleView;
            tabTitleView.setAlpha(1f);

        } else
            tabTitleView.setAlpha(0.5f);
        tabTitleView.setText(adapter.getPageTitle(i));
        tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
        //tabView.setOnClickListener(tabClickListener);
        mTabStrip.addView(tabView);
    }
}

From source file:com.juick.android.MainActivity.java

public static void restyleChildrenOrWidget(View view, boolean dontBackground) {
    if (view == null)
        return;/*from   ww  w  . j  a v a  2 s .c o m*/
    ColorsTheme.ColorTheme colorTheme = JuickMessagesAdapter.getColorTheme(view.getContext());
    boolean pressed = view.isPressed();
    boolean selected = view.isSelected();
    String name = view.getClass().getName();
    if (name.contains("$HomeView"))
        return;
    if (view instanceof AbsListView) {
        ((AbsListView) view).setCacheColorHint(colorTheme.getBackground(pressed));
    }
    if (view instanceof EditText) {
        EditText et = (EditText) view;
        et.setTextColor(colorTheme.getForeground(pressed));
        et.setBackgroundColor(colorTheme.getBackground(pressed));
    } else if (view instanceof RadioButton) {
        RadioButton btn = (RadioButton) view;
        btn.setTextColor(colorTheme.getForeground(pressed));
        btn.setBackgroundColor(colorTheme.getBackground());
    } else if (view instanceof Spinner) {
        View scan = view;
        boolean shouldRecolor = false;
        while (scan != null) {
            if (scan.getClass().getName().toLowerCase().contains("action")) {
                shouldRecolor = true;
                break;
            }
            if ("shouldRecolor".equals(scan.getTag())) {
                shouldRecolor = true;
                break;
            }
            try {
                scan = (View) scan.getParent();
            } catch (Exception e) {
                scan = null;
            }
        }
        if (shouldRecolor)
            restyleViewGroup((Spinner) view, colorTheme, pressed, selected, dontBackground);
    } else if (view instanceof Button) {
        //            Button btn = (Button) view;
        //            btn.setTextColor(colorTheme.getForeground(pressed));
        //            btn.setBackgroundColor(colorTheme.getButtonBackground());
    } else if (view instanceof TextView) {
        TextView text = (TextView) view;
        final int id = text.getId();
        if (id != R.id.old_title /* && id != R.id.gotoMain */) // keep it authentic
            text.setTextColor(colorTheme.getForeground(pressed));
    } else if (view instanceof ViewGroup) {
        restyleViewGroup((ViewGroup) view, colorTheme, pressed, selected, dontBackground);
    }
}

From source file:cn.mailchat.view.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    //layout//from  ww  w. ja v a 2s .  c om
    RelativeLayout tabLayout = new RelativeLayout(getContext());
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tabLayout.setLayoutParams(layoutParams);

    RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    //tab
    TextView tab = new TextView(getContext());
    tab.setId(100 + position);
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tabLayout.addView(tab, textParams);

    //???
    RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId());
    viewParams.addRule(RelativeLayout.CENTER_VERTICAL);
    View view = new View(getContext());
    ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(vParams);
    tabLayout.addView(view, viewParams);

    addTab(position, tabLayout);

}

From source file:info.staticfree.android.units.Units.java

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    switch (v.getId()) {
    case R.id.want:
        go();//from  w w w.  j av  a2  s  .  co m
        final InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

        return true;
    }
    return false;
}

From source file:edu.rowan.app.carousel.CarouselFeature.java

private void setupView() {
    imageView.setId(1);/*from  w  w w .  ja  v a 2 s  .  com*/
    RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.FILL_PARENT);
    imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    imageView.setLayoutParams(imageParams);
    //      imageView.setAdjustViewBounds(true);
    Resources r = context.getResources();
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics());

    TextView descriptionView = new TextView(context);
    descriptionView.setId(2);
    descriptionView.setPadding(padding, 0, padding, padding);
    descriptionView.setText(description);
    descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10));
    descriptionView.setTextColor(Color.WHITE);
    RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId());
    carouselView.addView(descriptionView, descParams);

    TextView titleView = new TextView(context);
    titleView.setText(title);
    titleView.setPadding(padding, 0, padding, 0);
    RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId());
    titleView.setLayoutParams(titleParams);
    titleView.setTextColor(Color.WHITE);
    titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0));
    titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);

    carouselView.addView(titleView);
}

From source file:com.yibairun.ui.components.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {
    //layout//from   ww w .  ja v  a2  s .c o  m
    RelativeLayout tabLayout = new RelativeLayout(getContext());
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tabLayout.setLayoutParams(layoutParams);

    RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    //tab
    TextView tab = new TextView(getContext());
    tab.setId(100 + position);
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tabLayout.addView(tab, textParams);

    //???
    RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId());
    viewParams.addRule(RelativeLayout.CENTER_VERTICAL);
    View view = new View(getContext());
    ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(vParams);
    tabLayout.addView(view, viewParams);

    BadgeView badgeView = new BadgeView(getContext(), view);
    badgeView.setTextSize(10);
    badgeView.setGravity(Gravity.CENTER);
    badgeView.setBadgePosition(BadgeView.POSITION_TOP_LEFT);
    badgeView.setTag(BAGE_TAG);

    addTab(position, tabLayout);

}

From source file:fr.cph.stock.android.activity.AccountActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "Account Activity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.account_activity);

    Bundle b = getIntent().getExtras();/*w w  w  .  j  a  v  a  2s  .  c om*/
    portfolio = b.getParcelable("portfolio");

    errorView = (TextView) findViewById(R.id.errorMessage);
    totalValueView = (TextView) findViewById(R.id.totalValue);
    totalGainView = (TextView) findViewById(R.id.totalGain);
    totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue);
    lastUpateView = (TextView) findViewById(R.id.lastUpdate);
    liquidityView = (TextView) findViewById(R.id.liquidity);
    yieldYearView = (TextView) findViewById(R.id.yieldYear);
    shareValueView = (TextView) findViewById(R.id.shareValue);
    gainView = (TextView) findViewById(R.id.gain2);
    perfView = (TextView) findViewById(R.id.perf);
    yieldView = (TextView) findViewById(R.id.yieldPerf);
    taxesView = (TextView) findViewById(R.id.taxes);

    RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout);
    TextView recent = new TextView(getApplicationContext());
    textViews = new ArrayList<TextView>();
    int id = 1;
    int nameID = 100;
    int viewId1 = 500;
    int currencyId = 1000;
    for (int i = 0; i < portfolio.getAccounts().size(); i++) {
        Account account = portfolio.getAccounts().get(i);
        TextView currentAccountNameTextView = new TextView(getApplicationContext());
        currentAccountNameTextView.setText(account.getName());
        currentAccountNameTextView.setTextColor(Color.GRAY);
        currentAccountNameTextView.setId(nameID);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        currentAccountNameTextView.setLayoutParams(params);
        accLayout.addView(currentAccountNameTextView, params);
        textViews.add(currentAccountNameTextView);

        View viewPoint1 = new View(getApplicationContext());
        viewPoint1.setId(viewId1);
        viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light));
        params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2);
        params.addRule(RelativeLayout.RIGHT_OF, nameID);
        params.addRule(RelativeLayout.LEFT_OF, currencyId);
        params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        viewPoint1.setLayoutParams(params);
        accLayout.addView(viewPoint1, params);

        TextView currentCurrencyTextView = new TextView(getApplicationContext());
        currentCurrencyTextView.setText(account.getCurrency());
        currentCurrencyTextView.setTextColor(Color.GRAY);
        currentCurrencyTextView.setId(currencyId);
        params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.CENTER_HORIZONTAL);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        currentCurrencyTextView.setLayoutParams(params);
        accLayout.addView(currentCurrencyTextView, params);
        textViews.add(currentCurrencyTextView);

        View viewPoint2 = new View(getApplicationContext());
        viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light));
        params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2);
        params.addRule(RelativeLayout.RIGHT_OF, currencyId);
        params.addRule(RelativeLayout.LEFT_OF, id);
        params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        viewPoint2.setLayoutParams(params);
        accLayout.addView(viewPoint2, params);

        TextView currentTextView = new TextView(getApplicationContext());
        currentTextView.setText(account.getLiquidity());
        currentTextView.setTextColor(Color.GRAY);
        currentTextView.setId(id);
        params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT,
                (int) LayoutParams.WRAP_CONTENT);
        if (i != 0) {
            params.addRule(RelativeLayout.BELOW, recent.getId());
        }
        params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        currentTextView.setLayoutParams(params);
        recent = currentTextView;
        accLayout.addView(currentTextView, params);
        textViews.add(currentTextView);

        id++;
        nameID++;
        viewId1++;
        currencyId++;
    }
    buildUi(false);
    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}

From source file:com.QuarkLabs.BTCeClient.fragments.HistoryFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mAdapter = new OrdersAdapter(getActivity(), mHistoryType);
    mListView = (ListView) getView().findViewById(R.id.HistoryContainer);
    final EditText startDate = (EditText) getView().findViewById(R.id.StartDateValue);
    final EditText endDate = (EditText) getView().findViewById(R.id.EndDateValue);
    startDate.setText(mDateFormat.format(mStartDateValue));
    endDate.setText(mDateFormat.format(mEndDateValue));
    Button makeQuery = (Button) getView().findViewById(R.id.MakeQueryButton);
    View.OnClickListener showDatePicker = new View.OnClickListener() {
        @Override/*from   www .j av  a2 s.co  m*/
        public void onClick(View v) {
            final TextView dateValue = (TextView) v;
            Date date = null;
            try {
                date = mDateFormat.parse(dateValue.getText().toString());
            } catch (ParseException e) {
                e.printStackTrace();
            }
            int year = 1999;
            int month = 0;
            int day = 1;
            if (date != null) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(date);
                year = calendar.get(Calendar.YEAR);
                month = calendar.get(Calendar.MONTH);
                day = calendar.get(Calendar.DAY_OF_MONTH);
            }

            DatePickerDialog datePickerDialog = new android.app.DatePickerDialog(getActivity(),
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                            Calendar calendar = Calendar.getInstance();
                            if (dateValue.getId() == R.id.StartDateValue) {
                                calendar.setTime(mStartDateValue);
                                calendar.set(year, monthOfYear, dayOfMonth, 0, 0, 0);
                                mStartDateValue = calendar.getTime();
                            } else {
                                calendar.setTime(mEndDateValue);
                                calendar.set(year, monthOfYear, dayOfMonth, 23, 59, 59);
                                mEndDateValue = calendar.getTime();
                            }
                            dateValue.setText(mDateFormat.format(calendar.getTime()));
                        }
                    }, year, month, day);
            datePickerDialog.getDatePicker().setCalendarViewShown(false);
            datePickerDialog.show();
        }
    };
    startDate.setOnClickListener(showDatePicker);
    endDate.setOnClickListener(showDatePicker);
    makeQuery.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Bundle bundle = new Bundle();
            bundle.putString("startDate", String.valueOf(mStartDateValue.getTime() / 1000));
            bundle.putString("endDate", String.valueOf(mEndDateValue.getTime() / 1000));
            getLoaderManager().restartLoader(mLoaderId, bundle, HistoryFragment.this);
            mListView.setAdapter(null);
            mNoItems.setVisibility(View.GONE);
            mListView.setEmptyView(mLoadingView);

        }
    });
    mLoadingView = (ProgressBar) getView().findViewById(R.id.Loading);
    mNoItems = (TextView) getView().findViewById(R.id.NoItems);
    mListView.setEmptyView(mLoadingView);
}

From source file:net.ibaixin.chat.view.PagerSlidingTabStrip.java

/**
 * tab/*from   w ww .  j a v a 2  s  .  c om*/
 * @update 2015128 ?9:58:54
 * @param position
 * @param title
 */
private void addTextTab(final int position, CharSequence title) {
    //layout
    RelativeLayout tabLayout = new RelativeLayout(getContext());
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    tabLayout.setLayoutParams(layoutParams);

    RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    //tab
    TextView tab = new TextView(getContext());
    tab.setId(100 + position);
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tabLayout.addView(tab, textParams);

    //???
    RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId());
    viewParams.addRule(RelativeLayout.CENTER_VERTICAL);
    View view = new View(getContext());
    ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    view.setLayoutParams(vParams);
    tabLayout.addView(view, viewParams);

    addTab(position, tabLayout);

}