Example usage for android.widget TextView setOnClickListener

List of usage examples for android.widget TextView setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.uddchina.youdingdan.MyDateActivity.java

/**
 * popupWindow/*from ww w.j  a va  2 s  .c om*/
 *
 * @param linearLayout
 */
private void show(LinearLayout linearLayout) {
    popupwindowShow = new PopupWindow(linearLayout, WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT);
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.picture_popupwindow_layout, null);
    popupwindowShow.setContentView(view);
    popupwindowShow.setFocusable(true);
    popupwindowShow.setOutsideTouchable(true);
    popupwindowShow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
    popupwindowShow.showAtLocation(linearLayout, Gravity.BOTTOM, 0, 0);
    TextView doPhoto = (TextView) view.findViewById(R.id.doPhoto);
    TextView choicePicture = (TextView) view.findViewById(R.id.choicePicture);
    TextView cansol = (TextView) view.findViewById(R.id.cansol);
    //?
    doPhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            doPhoto();
            popupwindowShow.dismiss();
        }
    });
    //
    choicePicture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            doPicture();
            popupwindowShow.dismiss();
        }
    });
    //?
    cansol.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            popupwindowShow.dismiss();
        }
    });
}

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private void addItem() {
    for (int i = 0; i < actionItems.size(); i++) {
        View item = makeItem(actionItems.get(i), i);
        if (item != null) {
            sheetContainer.addView(item);
            sheetContainer.addView(createLine());
        }//www. j a v  a  2s .  c om
    }

    for (int i = 0; i < actionItems.size(); i++) {
        Pair<String, String> item = actionItems.get(i);
        if ("1".equals(item.first)) {
            if (hasCancelItemAdded) {
                if (actionListener != null) {
                    actionListener.onError("Can only add most 1 item with type 1");
                }
                return;
            }
            TextView textView = createItemBase();
            textView.setText(item.second);
            textView.setTextColor(COLOR_ITEM_NORMAL);
            textView.getPaint().setFakeBoldText(true);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    dp2px(48));
            lp.topMargin = dp2px(8);
            textView.setLayoutParams(lp);
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (actionListener != null) {
                        actionListener.onCancel();
                        dismiss();
                    }
                }
            });
            sheetContainer.addView(textView);
            hasCancelItemAdded = true;
        }
    }
}

From source file:com.timothy.android.api.fragment.PageFragment.java

public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) {
    Log.i(LOG_TAG, "setAllComponent()...");
    for (HtmlCleanAPI.HtmlContent hc : hcList) {
        String tag = hc.getTag();
        String content = hc.getContent();
        String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(StringUtil.mergeBlank(content)));
        String contentRSpecial = StringUtil.rmvSpecial(contentRBlank);

        if (StringUtil.isEmpty(content) || StringUtil.isEmpty(contentRBlank)
                || StringUtil.isEmpty(contentRSpecial)) {
            continue;
        }/*from  ww w. j  av a  2s .  com*/

        Log.i(LOG_TAG, "tag:" + tag);
        Log.i(LOG_TAG, "content:" + content);

        if (tag.equalsIgnoreCase("P")) {
            final TextView tagPTV = new TextView(mContext);
            tagPTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagPTV.setLayoutParams(lp);
            tagPTV.setPadding(3, 3, 3, 3);
            tagPTV.setPaddingRelative(3, 3, 3, 3);
            tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPTV.setTextColor(Color.BLACK);
            tagPTV.setText(contentRSpecial);
            tagPTV.setTextSize(TEXT_SIZE);
            tagPTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPTV);

        } else if (tag.equalsIgnoreCase("pre")) {
            final TextView tagPre = new TextView(mContext);
            tagPre.setBackgroundColor(Color.parseColor("#D2EADE"));
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagPre.setLayoutParams(lp);
            tagPre.setPadding(2, 2, 2, 2);
            tagPre.setPaddingRelative(2, 2, 2, 2);
            tagPre.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPre.setTextColor(Color.BLACK);
            //            String contentRSpecial = StringUtil.rmvSpecial(content);
            tagPre.setText(StringUtil.rmvSpecial(content));
            tagPre.setTextSize(TEXT_SIZE);
            tagPre.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPre.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPre);
        } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2")
                || tag.equalsIgnoreCase("H3")) {//title
            TextView tagDtHTV = new TextView(mContext);
            tagDtHTV.setBackgroundColor(Color.DKGRAY);
            tagDtHTV.setTypeface(null, Typeface.BOLD);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 0, 2, 0);
            tagDtHTV.setLayoutParams(lp);
            tagDtHTV.setPadding(2, 2, 2, 2);
            tagDtHTV.setPaddingRelative(2, 2, 2, 2);
            tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDtHTV.setTextColor(Color.WHITE);
            tagDtHTV.setText(contentRSpecial);
            tagDtHTV.setTextSize(TEXT_SIZE);
            lineLayout.addView(tagDtHTV);
        } else if (tag.equalsIgnoreCase("dd")) {
            final TextView tagDD = new TextView(mContext);
            tagDD.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagDD.setLayoutParams(lp);
            tagDD.setPadding(3, 3, 3, 3);
            tagDD.setPaddingRelative(3, 3, 3, 3);
            tagDD.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDD.setTextColor(Color.BLACK);
            tagDD.setText(contentRSpecial);
            tagDD.setTextSize(TEXT_SIZE);
            tagDD.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagDD.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagDD);
        } else if (tag.equalsIgnoreCase("li")) {
            final TextView tagLigTV = new TextView(mContext);
            tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagLigTV.setLayoutParams(lp);
            tagLigTV.setPaddingRelative(2, 2, 2, 2);
            tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagLigTV.setTextColor(Color.BLACK);
            tagLigTV.setText(contentRSpecial);
            tagLigTV.setTextSize(TEXT_SIZE);
            tagLigTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagLigTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagLigTV);
        } else if (tag.equalsIgnoreCase("img")) {
            final TextView imgTV = new TextView(mContext);
            imgTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            imgTV.setLayoutParams(lp);
            imgTV.setPaddingRelative(2, 2, 2, 2);
            imgTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            imgTV.setTextColor(Color.BLACK);
            imgTV.setText(content);
            imgTV.setTextSize(TEXT_SIZE);
            imgTV.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    TextView tv = (TextView) v;
                    String path = tv.getText().toString();
                    if (path != null && path.trim().length() > 0) {
                        openDialog2(path);
                    }
                }
            });
            lineLayout.addView(imgTV);
        }
    }
}

From source file:de.enlightened.peris.IntroScreen.java

@SuppressLint("NewApi")
public final void onCreate(final Bundle savedInstanceState) {
    this.dbHelper = new PerisDBHelper(this);
    final Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        if (bundle.containsKey("server_id")) {
            if (bundle.getString("server_id") != null) {

                this.incomingShortcut = true;
                this.shortcutServerId = bundle.getString("server_id");
            }//from ww  w .j a v  a  2 s.c  o m
        }
    }

    final PerisApp app = (PerisApp) getApplication();
    app.initSession();

    startService(new Intent(this, MailService.class));
    this.initDatabase();

    final SharedPreferences appPreferences = getSharedPreferences("prefs", 0);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    final SharedPreferences.Editor editor = appPreferences.edit();
    editor.putString("server_address", getString(R.string.server_location));
    editor.commit();

    final String backgroundColor = app.getSession().getServer().serverColor;

    ThemeSetter.setTheme(this, backgroundColor);

    super.onCreate(savedInstanceState);

    ThemeSetter.setActionBar(this, backgroundColor);

    //Track app analytics
    this.ah = ((PerisApp) getApplication()).getAnalyticsHelper();
    this.ah.trackScreen(getString(R.string.app_name) + " v" + getString(R.string.app_version) + " for Android",
            true);

    setContentView(R.layout.intro_screen);

    this.serverInputter = (EditText) findViewById(R.id.intro_screen_add_server_box);

    final Button serverAdder = (Button) findViewById(R.id.intro_screen_submit_new_server);

    serverAdder.setOnClickListener(new View.OnClickListener() {

        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                new ServerValidationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                        serverInputter.getText().toString().trim());
            } else {
                new ServerValidationTask().execute(serverInputter.getText().toString().trim());
            }

        }
    });

    this.lvServers = (ListView) findViewById(R.id.intro_screen_server_list);
    this.gvServers = (GridView) findViewById(R.id.intro_screen_server_grid);

    if (this.lvServers == null) {
        registerForContextMenu(this.gvServers);
        this.gvServers.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("checkstyle:requirethis")
            public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                final Server server = serverList.get(position);
                connectToServer(server);
            }
        });
    } else {
        this.lvServers.setDivider(null);
        registerForContextMenu(this.lvServers);

        this.lvServers.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("checkstyle:requirethis")
            public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                final Server server = serverList.get(position);
                connectToServer(server);
            }
        });
    }

    final TextView tvTapaShoutout = (TextView) findViewById(R.id.intro_screen_app_title);
    tvTapaShoutout.setOnClickListener(new View.OnClickListener() {

        public void onClick(final View v) {
            final Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/McNetic/peris"));
            startActivity(browserIntent);
        }
    });

    //Check for incoming link from tapatalk :-)
    String host = "";

    final Uri data = getIntent().getData();

    if (data != null) {
        host = data.getHost();
        this.stealingType = data.getQueryParameter("location");

        if (this.stealingType == null) {
            this.stealingType = "0";
        } else {
            if (this.stealingType.contentEquals("forum")) {
                final String forumId = data.getQueryParameter("fid");

                if (forumId == null) {
                    this.stealingLocation = "0";
                } else {
                    this.stealingLocation = forumId;
                }
            }

            if (this.stealingType.contentEquals("topic")) {
                final String topicId = data.getQueryParameter("tid");

                if (topicId == null) {
                    this.stealingLocation = "0";
                } else {
                    this.stealingLocation = topicId;
                }
            }
        }

    }

    if (host.length() > 0) {
        this.linkToSteal = host;
        this.stealingLink = true;
        return;
    }

}

From source file:com.zhongsou.souyue.ui.indicator.IcommonTabPageIndicator.java

private void addTab(CharSequence text, int index) {
    //      final TabView tabView = new TabView(getContext());
    //      tabView.mIndex = index;
    final TextView tabView = new TextView(getContext());
    tabView.setTag(index);/* www .j  av a  2  s  .  c  o m*/
    //      if (index == 0){
    //         doSetTextStyle(tabView, R.drawable.sy_indicator_icommentary_left);
    //      } else if (index == count - 1){
    //         doSetTextStyle(tabView, R.drawable.sy_indicator_icommentary_right);
    //      } else {
    //         doSetTextStyle(tabView, R.drawable.sy_indicator_icommentary_middle);
    //      }
    tabView.setBackgroundResource(R.drawable.vpi__tab_indicator_blue_line);
    tabView.setTextColor(getResources().getColor(R.color.bar_center_title_color));
    tabView.setGravity(Gravity.CENTER);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    tabView.setPadding(30, 0, 30, 0);
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setText(text);

    mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, FILL_PARENT, 1));
}

From source file:de.grobox.liberario.DirectionsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // remember view for UI changes when fragment is not active
    mView = inflater.inflate(R.layout.fragment_directions, container, false);
    locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);

    checkPreferences();/*from   ww w.jav  a2s. c  om*/

    setFromUI();
    setToUI();

    // timeView
    final Button timeView = (Button) mView.findViewById(R.id.timeView);
    timeView.setText(DateUtils.getcurrentTime(getActivity()));
    timeView.setTag(Calendar.getInstance());
    timeView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showTimePickerDialog();
        }
    });

    // set current time on long click
    timeView.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            timeView.setText(DateUtils.getcurrentTime(getActivity()));
            timeView.setTag(Calendar.getInstance());
            return true;
        }
    });

    Button plus10Button = (Button) mView.findViewById(R.id.plus15Button);
    plus10Button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            addToTime(15);
        }
    });

    // dateView
    final Button dateView = (Button) mView.findViewById(R.id.dateView);
    dateView.setText(DateUtils.getcurrentDate(getActivity()));
    dateView.setTag(Calendar.getInstance());
    dateView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            showDatePickerDialog();
        }
    });

    // set current date on long click
    dateView.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            dateView.setText(DateUtils.getcurrentDate(getActivity()));
            dateView.setTag(Calendar.getInstance());
            return true;
        }
    });

    // Trip Date Type Spinner (departure or arrival)
    final TextView dateType = (TextView) mView.findViewById(R.id.dateType);
    dateType.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (dateType.getText().equals(getString(R.string.trip_dep))) {
                dateType.setText(getString(R.string.trip_arr));
            } else {
                dateType.setText(getString(R.string.trip_dep));
            }
        }
    });

    // Products
    final ViewGroup productsLayout = (ViewGroup) mView.findViewById(R.id.productsLayout);
    for (int i = 0; i < productsLayout.getChildCount(); ++i) {
        final ImageView productView = (ImageView) productsLayout.getChildAt(i);
        final Product product = Product.fromCode(productView.getTag().toString().charAt(0));

        // make inactive products gray
        if (mProducts.contains(product)) {
            productView.getDrawable().setColorFilter(null);
        } else {
            productView.getDrawable().setColorFilter(getResources().getColor(R.color.highlight),
                    PorterDuff.Mode.SRC_ATOP);
        }

        // handle click on product icon
        productView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (mProducts.contains(product)) {
                    productView.getDrawable().setColorFilter(getResources().getColor(R.color.highlight),
                            PorterDuff.Mode.SRC_ATOP);
                    mProducts.remove(product);
                    Toast.makeText(v.getContext(), LiberarioUtils.productToString(v.getContext(), product),
                            Toast.LENGTH_SHORT).show();
                } else {
                    productView.getDrawable().setColorFilter(null);
                    mProducts.add(product);
                    Toast.makeText(v.getContext(), LiberarioUtils.productToString(v.getContext(), product),
                            Toast.LENGTH_SHORT).show();
                }
            }
        });

        // handle long click on product icon by showing product name
        productView.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Toast.makeText(view.getContext(), LiberarioUtils.productToString(view.getContext(), product),
                        Toast.LENGTH_SHORT).show();
                return true;
            }
        });
    }

    if (!Preferences.getPref(getActivity(), Preferences.SHOW_ADV_DIRECTIONS)) {
        (mView.findViewById(R.id.productsScrollView)).setVisibility(View.GONE);
    }

    Button searchButton = (Button) mView.findViewById(R.id.searchButton);
    searchButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            NetworkProvider np = NetworkProviderFactory.provider(Preferences.getNetworkId(getActivity()));
            if (!np.hasCapabilities(NetworkProvider.Capability.TRIPS)) {
                Toast.makeText(v.getContext(), v.getContext().getString(R.string.error_no_trips_capability),
                        Toast.LENGTH_SHORT).show();
                return;
            }

            AsyncQueryTripsTask query_trips = new AsyncQueryTripsTask(v.getContext());

            // check and set to location
            if (checkLocation(FavLocation.LOC_TYPE.TO)) {
                query_trips.setTo(getLocation(FavLocation.LOC_TYPE.TO));
            } else {
                Toast.makeText(getActivity(), getResources().getString(R.string.error_invalid_to),
                        Toast.LENGTH_SHORT).show();
                return;
            }

            // check and set from location
            if (mGpsPressed) {
                if (getLocation(FavLocation.LOC_TYPE.FROM) != null) {
                    query_trips.setFrom(getLocation(FavLocation.LOC_TYPE.FROM));
                } else {
                    mAfterGpsTask = query_trips;

                    pd = new ProgressDialog(getActivity());
                    pd.setMessage(getResources().getString(R.string.stations_searching_position));
                    pd.setCancelable(false);
                    pd.setIndeterminate(true);
                    pd.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel",
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    mAfterGpsTask = null;
                                    dialog.dismiss();
                                }
                            });
                    pd.show();
                }
            } else {
                if (checkLocation(FavLocation.LOC_TYPE.FROM)) {
                    query_trips.setFrom(getLocation(FavLocation.LOC_TYPE.FROM));
                } else {
                    Toast.makeText(getActivity(), getString(R.string.error_invalid_from), Toast.LENGTH_SHORT)
                            .show();
                    return;
                }
            }

            // remember trip if not from GPS
            if (!mGpsPressed) {
                FavDB.updateFavTrip(getActivity(), new FavTrip(getLocation(FavLocation.LOC_TYPE.FROM),
                        getLocation(FavLocation.LOC_TYPE.TO)));
            }

            // set date
            query_trips.setDate(DateUtils.mergeDateTime(getActivity(), dateView.getText(), timeView.getText()));

            // set departure to true of first item is selected in spinner
            query_trips.setDeparture(dateType.getText().equals(getString(R.string.trip_dep)));

            // set products
            query_trips.setProducts(mProducts);

            // don't execute if we still have to wait for GPS position
            if (mAfterGpsTask != null)
                return;

            query_trips.execute();
        }
    });

    return mView;
}

From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java

@Override
public void onBindViewHolder(ViewHolder viewHolder, final int position) {
    Log.e(TAG, "onBindViewHolder #" + position);

    // Get element from your dataset at this position and replace the contents of the view
    // with that element
    View v = viewHolder.getVh();//from  ww  w  .j  av  a 2 s.c om
    final ImageView ivToyImage = viewHolder.getIvToyImage();
    final TextView textView = viewHolder.getTvTitle();
    final FlipImageView flipImageView = viewHolder.getFlipImageView();

    View.OnClickListener l = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String strPid = mDataSet.get(position).getStrPid();

            if (mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST).contains(strPid)) {
                mPref.removeStringArrayListItem(SharedPref.PREF_FAVORITE_LIST, strPid);
            } else {
                mPref.addStringArrayListItem(SharedPref.PREF_FAVORITE_LIST, strPid);
            }
            flipImageView.toggleFlip();
        }
    };
    textView.setOnClickListener(l);
    flipImageView.setOnClickListener(l);

    viewHolder.getTvLoadingBackground().setBackgroundColor(getPastelRBG());
    viewHolder.getTvLoading().setText("ToyToI");
    if (-1 < position && position < mDataSet.size()) {
        setItemSize(v);

        mFavList = mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST);
        if (mFavList.contains(mDataSet.get(position).getStrPid())) {
            flipImageView.setFlipped(true);
        } else {
            flipImageView.setFlipped(false);
        }

        final Toy toy = mDataSet.get(position);

        String bgImage = Config.HOST_SERVER_URL + toy.getImage().replace("..", "");
        String strTitle = toy.getTitle();
        textView.setText(strTitle);//

        ImageLoadingListener fadeImageLoadingListener = new ImageLoadingListener() {

            long ANIM_DURATION = 500;

            @Override
            public void onLoadingStarted(String s, View view) {
                view.clearAnimation();
                ((ImageView) view).setImageResource(R.drawable.alpha_zero);
            }

            @Override
            public void onLoadingFailed(String s, View view, FailReason failReason) {
                Toast.makeText(view.getContext(), "Network Error : " + failReason.getType().toString(),
                        Toast.LENGTH_LONG).show();
                ((TextView) ((FrameLayout) view.getParent()).findViewById(R.id.tvLoading)).setText("Error");
                Log.e(TAG, "onLoadingFailed :" + s);
            }

            @Override
            public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                ((ImageView) view).setImageBitmap(bitmap);
                Animation fadeIn = new AlphaAnimation(0, 1);
                fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
                fadeIn.setDuration(ANIM_DURATION);
                view.clearAnimation();
                view.startAnimation(fadeIn);
            }

            @Override
            public void onLoadingCancelled(String s, View view) {
                if (view != null) {
                    ((TextView) ((FrameLayout) view.getParent()).findViewById(R.id.tvLoading)).setText("Error");
                    Log.e(TAG, "onLoadingCancelled :" + s);
                }
            }
        };

        App.getImageLoader(v.getContext()).displayImage(bgImage, ivToyImage, fadeImageLoadingListener);
        ivToyImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                AsyncHttpClient asyncHttpClient = new AsyncHttpClient();

                asyncHttpClient.get(v.getContext(), Config.URL_DETAIL + mDataSet.get(position).getStrPid(),
                        new AsyncHttpResponseHandler() {

                            @Override
                            public void onSuccess(int i, Header[] headers, byte[] bytes) {
                                String responseStr = new String(bytes);
                                Context context = v.getContext();

                                Bundle bundle = new Bundle();
                                Gson gson = new Gson();
                                Product[] products = gson.fromJson(responseStr, Product[].class);

                                Intent intent = new Intent(context,
                                        FlexibleSpaceWithImageRecyclerViewActivity.class);
                                intent.putExtra("Products", gson.toJson(products));
                                intent.putExtra("title", toy.getTitle());
                                intent.putExtra("image", toy.getImage());
                                intent.putExtra("favorite",
                                        mPref.getStringArrayList(SharedPref.PREF_FAVORITE_LIST)
                                                .contains(toy.getStrPid()));
                                context.startActivity(intent);

                                //changeFragment
                            }

                            private void changeFragment(Bundle bundle) {
                                Fragment fragment = new ProductListViewFragment();
                                fragment.setArguments(bundle);

                                FragmentTransaction transaction = ((FragmentActivity) v.getContext())
                                        .getSupportFragmentManager().beginTransaction();
                                transaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.popenter,
                                        R.anim.popexit);
                                transaction.addToBackStack(getClass().getSimpleName());
                                transaction.replace(R.id.toyListViewWraper, fragment);
                                transaction.commit();
                            }

                            @Override
                            public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {

                            }
                        });

                Log.d(TAG, "Element " + position + " clicked.");
                mClickedPostion = position;
                //
            }
        });
    }

}

From source file:com.frostwire.android.gui.fragments.SearchFragment.java

@Override
public View getHeader(Activity activity) {
    LayoutInflater inflater = LayoutInflater.from(activity);
    LinearLayout header = (LinearLayout) inflater.inflate(R.layout.view_search_header, null, false);
    TextView title = header.findViewById(R.id.view_search_header_text_title);
    title.setText(R.string.search);/*from   w  ww.  j av  a2 s  .c o m*/
    title.setOnClickListener(getHeaderClickListener());
    ImageButton filterButtonIcon = header.findViewById(R.id.view_search_header_search_filter_button);
    TextView filterCounter = header.findViewById(R.id.view_search_header_search_filter_counter);
    filterButton = new FilterToolbarButton(filterButtonIcon, filterCounter);
    filterButton.updateVisibility();
    return header;
}

From source file:com.github.topbottomsnackbar.TBSnackbar.java

/**
 * Set the action to be displayed in this {@link TBSnackbar}.
 *
 * @param text     Text to display//w  w  w. ja  v  a2  s .  co  m
 * @param listener callback to be invoked when the action is clicked
 */
@NonNull
public TBSnackbar setAction(CharSequence text, final View.OnClickListener listener) {
    final TextView tv = mView.getActionView();

    if (TextUtils.isEmpty(text) || listener == null) {
        tv.setVisibility(View.GONE);
        tv.setOnClickListener(null);
    } else {
        tv.setVisibility(View.VISIBLE);
        tv.setText(text);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onClick(view);
                // Now dismiss the TBSnackbar
                dispatchDismiss(Callback.DISMISS_EVENT_ACTION);
            }
        });
    }
    return this;
}

From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java

public void showActionSheet() {

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    final Dialog myDialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
    myDialog.setCanceledOnTouchOutside(true);
    myDialog.getWindow().setLayout(AbsoluteLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    myDialog.getWindow().setGravity(Gravity.BOTTOM);
    myDialog.getWindow().getAttributes().windowAnimations = R.anim.slide_up;
    WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes();
    lp.dimAmount = 0.75f;//from ww  w  .  ja v a 2 s .  co  m
    myDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    myDialog.getWindow();

    View dialoglayout = inflater.inflate(R.layout.dialog_profile_actionsheet, null);
    myDialog.setContentView(dialoglayout);
    TextView mTvTakeFromCamera = (TextView) myDialog.findViewById(R.id.tvTakeFromCamera);
    TextView mTvTakeFromLibrary = (TextView) myDialog.findViewById(R.id.tvTakeFromLibrary);

    long timestamp = System.currentTimeMillis();
    AppData.getSingletonObject().setmFileTemp(getActivity(), "" + timestamp);
    mTvTakeFromCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            myDialog.dismiss();
            takePicture(getActivity());

        }

    });

    mTvTakeFromLibrary.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            myDialog.dismiss();
            openGallery(getActivity());
        }

    });

    TextView tvCancel = (TextView) myDialog.findViewById(R.id.tvCancel);

    tvCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            myDialog.dismiss();
        }

    });

    try {
        myDialog.show();
    } catch (WindowManager.BadTokenException e) {

        Log.e("", "View not attached.");
    } catch (Exception e) {

        e.printStackTrace();
    }
}