Example usage for android.widget TextView setClickable

List of usage examples for android.widget TextView setClickable

Introduction

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

Prototype

public void setClickable(boolean clickable) 

Source Link

Document

Enables or disables click events for this view.

Usage

From source file:edu.cwru.apo.Directory.java

private void loadTable() {
    ProgressDialog progDialog = ProgressDialog.show(this, "Loading", "Please Wait", false);
    userTable.removeAllViews();//from w w w  .java 2s.  c  om
    Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, null, null,
            null, null, "first");
    String rowText = "";
    TableRow row;
    TextView text;
    if (!results.moveToFirst())
        return;
    while (!results.isAfterLast()) {
        String phoneNumber = removeNonDigits(results.getString(3));
        if (!(phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null"))) {
            rowText = results.getString(0) + " " + results.getString(1) + " [" + results.getString(2) + "]";
            row = new TableRow(this);
            text = new TextView(this);
            row.setPadding(0, 5, 0, 5);
            text.setClickable(true);
            text.setOnClickListener(this);
            //text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            text.setText(rowText);
            userTable.addView(row);
            row.addView(text);
        }
        results.moveToNext();
    }
    progDialog.cancel();
}

From source file:android.melbournehistorymap.MapsActivity.java

public void hideTile(View view) {
    TextView fab = (TextView) findViewById(R.id.fab);
    FloatingActionButton shareIcon = (FloatingActionButton) findViewById(R.id.shareIcon);
    //show small tile
    smallTile.setVisibility(View.VISIBLE);
    fab.setVisibility(View.VISIBLE);
    //hide big tile
    expandedTile.setVisibility(View.GONE);
    shareIcon.setVisibility(View.GONE);

    //unlock the map
    mMap.getUiSettings().setAllGesturesEnabled(true);

    //enable mapicon from being clickable
    TextView mapIcon = (TextView) findViewById(R.id.iconMap);
    mapIcon.setClickable(true);
}

From source file:android.melbournehistorymap.MapsActivity.java

public void expandTile(View view) {
    //        Toast.makeText(MapsActivity.this, "Expand", Toast.LENGTH_SHORT).show();
    TextView fab = (TextView) findViewById(R.id.fab);
    FloatingActionButton shareIcon = (FloatingActionButton) findViewById(R.id.shareIcon);
    //hide small tile
    smallTile.setVisibility(View.GONE);
    fab.setVisibility(View.GONE);
    //show big tile
    expandedTile.setVisibility(View.VISIBLE);
    shareIcon.setVisibility(View.VISIBLE);

    //lock the map
    mMap.getUiSettings().setAllGesturesEnabled(false);

    //Reset ScrollView to top
    ScrollView scrollView = (ScrollView) findViewById(R.id.scrollViewDesc);
    scrollView.fullScroll(View.FOCUS_UP);

    //disable mapicon from being clickable
    TextView mapIcon = (TextView) findViewById(R.id.iconMap);
    mapIcon.setClickable(false);
}

From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java

/** Build and add "moderator" tab. */
private void setupModeratorTab(Cursor sessionsCursor) {
    final TabHost host = getTabHost();

    // Insert Moderator when available
    final View moderatorBlock = findViewById(R.id.moderator_block);
    final String moderatorLink = sessionsCursor.getString(SessionsQuery.MODERATOR_LINK);
    final boolean validModerator = !TextUtils.isEmpty(moderatorLink);
    if (validModerator) {
        mModeratorUri = Uri.parse(moderatorLink);

        // Set link, but handle clicks manually
        final TextView textView = (TextView) findViewById(R.id.moderator_link);
        textView.setText(mModeratorUri.toString());
        textView.setMovementMethod(null);
        textView.setClickable(true);
        textView.setFocusable(true);/*from w  w w. j  av a 2s .co  m*/

        // Start background fetch of moderator status
        startModeratorStatusFetch(moderatorLink);

        moderatorBlock.setVisibility(View.VISIBLE);
    } else {
        moderatorBlock.setVisibility(View.GONE);
    }

    // Insert Wave when available
    final View waveBlock = findViewById(R.id.wave_block);
    final String waveLink = sessionsCursor.getString(SessionsQuery.WAVE_LINK);
    final boolean validWave = !TextUtils.isEmpty(waveLink);
    if (validWave) {
        // Rewrite incoming Wave URL to punch through user-agent check
        mWaveUri = Uri.parse(waveLink).buildUpon().appendQueryParameter("nouacheck", "1").build();

        // Set link, but handle clicks manually
        final TextView textView = (TextView) findViewById(R.id.wave_link);
        textView.setText(mWaveUri.toString());
        textView.setMovementMethod(null);
        textView.setClickable(true);
        textView.setFocusable(true);

        waveBlock.setVisibility(View.VISIBLE);
    } else {
        waveBlock.setVisibility(View.GONE);
    }

    if (validModerator || validWave) {
        // Moderator content comes from existing layout
        host.addTab(host.newTabSpec(TAG_MODERATOR).setIndicator(buildIndicator(R.string.session_interact))
                .setContent(R.id.tab_session_moderator));
    }
}

From source file:cs.umass.edu.prepare.view.custom.CalendarAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;//from ww  w. j a v  a 2  s .c o  m
    TextView dayView;
    if (convertView == null) { // if it's not recycled, initialize some attributes
        v = View.inflate(context, R.layout.calendar_item, null);
    }

    ViewGroup insertPoint = (ViewGroup) v.findViewById(R.id.layout_calendar_item);
    insertPoint.removeAllViews();

    dayView = (TextView) View.inflate(context, R.layout.textview_date, null);
    insertPoint.addView(dayView);

    // disable empty days from the beginning
    if (dateStrings[position].equals("")) {
        dayView.setClickable(false);
        dayView.setFocusable(false);
    } else {
        v.setBackgroundResource(R.drawable.list_item_background);
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, month.get(Calendar.YEAR));
        cal.set(Calendar.MONTH, month.get(Calendar.MONTH));
        cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStrings[position]));
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
        if (month.get(Calendar.YEAR) == selectedDate.get(Calendar.YEAR)
                && month.get(Calendar.MONTH) == selectedDate.get(Calendar.MONTH)
                && dateStrings[position].equals("" + selectedDate.get(Calendar.DAY_OF_MONTH))) {
            int selectedColor = ContextCompat.getColor(context,
                    R.color.color_calendar_item_background_selected);
            v.setBackgroundColor(selectedColor);
        } else if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) {
            dayView.setTextColor(Color.GRAY);
        }
    }
    dayView.setText(dateStrings[position]);

    // create date string for comparison
    String dateStr = dateStrings[position];

    if (displayType == DisplayType.BASIC) {
        v.setMinimumHeight(0);
        return v; // do not populate cells
    }
    v.setMinimumHeight(325); // TODO: not device independent

    if (medications == null || adherenceData == null) {
        Log.w(TAG, "Warning : No adherenceData found.");
        return v; // do not populate cells
    }

    if (dateStr.equals(""))
        return v;

    Calendar dateKey = Utils.getDateKey(month.get(Calendar.YEAR), month.get(Calendar.MONTH),
            Integer.parseInt(dateStr));
    if (adherenceData.containsKey(dateKey)) {
        populateCell(dateKey, insertPoint);
    }

    return v;
}

From source file:com.mohamadamin.fastsearch.free.modules.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  w  w  w.j ava  2s  .co  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);
    textView.setClickable(true);

    int paddingSide = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    int paddingTop = (int) (9 * getResources().getDisplayMetrics().density);
    int paddingBottom = (int) (12 * getResources().getDisplayMetrics().density);
    textView.setPadding(paddingSide, paddingTop, paddingSide, paddingBottom);

    return textView;
}

From source file:ir.mohandesplus.examnight.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//  w ww  . j  a va 2 s .  co  m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);
    textView.setClickable(true);

    int paddingSide = (int) (TAB_VIEW_PADDING_SIDE_DIPS * getResources().getDisplayMetrics().density);
    int paddingTop = (int) (10 * getResources().getDisplayMetrics().density);
    int paddingBottom = (int) (13 * getResources().getDisplayMetrics().density);
    textView.setPadding(paddingSide, paddingTop, paddingSide, paddingBottom);

    return textView;
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private boolean setView(int id, String packageName) {
    TextView donate = (TextView) findViewById(id);
    PackageManager pm = getPackageManager();
    try {//from w  w w .ja va  2 s  .co m
        ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
        if (!info.enabled) {
            return false;
        }
        CharSequence label = getLabel(pm, info);
        donate.setContentDescription(label);
        donate.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(pm.getApplicationIcon(info)), null,
                null);
        donate.setText(label);
        donate.setClickable(true);
        donate.setOnClickListener(this);
        donate.setVisibility(View.VISIBLE);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        UILog.d("cannot find package " + packageName, e);
        return false;
    }
}

From source file:net.etuldan.sparss.fragment.EntriesListFragment.java

@Override
public View inflateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_entry_list, container, true);

    if (mEntriesCursorAdapter != null) {
        setListAdapter(mEntriesCursorAdapter);
    }//from   ww w.j a  v a2  s.  co m

    mListView = (ListView) rootView.findViewById(android.R.id.list);
    mListView.setOnTouchListener(new SwipeGestureListener(mListView.getContext()));

    if (PrefUtils.getBoolean(PrefUtils.DISPLAY_TIP, true)) {
        final TextView header = new TextView(mListView.getContext());
        header.setMinimumHeight(UiUtils.dpToPixel(70));
        int footerPadding = UiUtils.dpToPixel(10);
        header.setPadding(footerPadding, footerPadding, footerPadding, footerPadding);
        header.setText(R.string.tip_sentence);
        header.setGravity(Gravity.CENTER_VERTICAL);
        header.setCompoundDrawablePadding(UiUtils.dpToPixel(5));
        header.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_info_outline, 0, R.drawable.ic_cancel, 0);
        header.setClickable(true);
        header.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mListView.removeHeaderView(header);
                PrefUtils.putBoolean(PrefUtils.DISPLAY_TIP, false);
            }
        });
        mListView.addHeaderView(header);
    }

    UiUtils.addEmptyFooterView(mListView, 90);

    mHideReadButton = (FloatingActionButton) rootView.findViewById(R.id.hide_read_button);
    mHideReadButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            UiUtils.displayHideReadButtonAction(mListView.getContext());
            return true;
        }
    });
    UiUtils.updateHideReadButton(mHideReadButton);

    mSearchView = (SearchView) rootView.findViewById(R.id.searchView);
    if (savedInstanceState != null) {
        refreshUI(); // To hide/show the search bar
    }

    mSearchView.post(new Runnable() { // Do this AFTER the text has been restored from saveInstanceState
        @Override
        public void run() {
            mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String s) {
                    InputMethodManager imm = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(mSearchView.getWindowToken(), 0);
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String s) {
                    setData(EntryColumns.SEARCH_URI(s), true);
                    return false;
                }
            });
        }
    });

    disableSwipe();

    return rootView;
}

From source file:com.example.oris1991.anotherme.ExternalCalendar.CalendarAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;//from w w  w  . ja  va 2  s. c  o  m
    TextView dayView;
    if (convertView == null) { // if it's not recycled, initialize some
        // attributes
        LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.calendar_item, null);

    }
    dayView = (TextView) v.findViewById(R.id.date);
    // separates daystring into parts.
    String[] separatedTime = dayString.get(position).split("-");
    // taking last part of date. ie; 2 from 2012-12-02
    String gridvalue = separatedTime[2].replaceFirst("^0*", "");
    // checking whether the day is in current month or not.
    if ((Integer.parseInt(gridvalue) > 1) && (position < firstDay)) {
        // setting offdays to white color.
        dayView.setTextColor(ContextCompat.getColor(mContext, R.color.summer));
        dayView.setClickable(false);
        dayView.setFocusable(false);
    } else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
        dayView.setTextColor(ContextCompat.getColor(mContext, R.color.summer));
        dayView.setClickable(false);
        dayView.setFocusable(false);
    } else {
        // setting curent month's days in blue color.
        dayView.setTextColor(ContextCompat.getColor(mContext, R.color.colorPrimary));
    }

    if (dayString.get(position).equals(curentDateString)) {
        setSelected(v);
        previousView = v;
    } else {
        v.setBackgroundResource(R.drawable.list_item_background);
    }
    dayView.setText(gridvalue);

    // create date string for comparison
    String date = dayString.get(position);

    if (date.length() == 1) {
        date = "0" + date;
    }
    String monthStr = "" + (month.get(GregorianCalendar.MONTH) + 1);
    if (monthStr.length() == 1) {
        monthStr = "0" + monthStr;
    }

    // show icon if date is not empty and it exists in the items array
    ImageView iw = (ImageView) v.findViewById(R.id.date_icon);
    if (date.length() > 0 && items != null && items.contains(date)) {
        iw.setVisibility(View.VISIBLE);
    } else {
        iw.setVisibility(View.INVISIBLE);
    }
    return v;
}