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:cn.ucai.fulicenter.adapter.MessageAdapter.java

private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) {
    try {/*from  w  w  w  .  j ava 2  s  .c  o m*/
        parentView.removeAllViews();
        for (int i = 0; i < jsonArr.length(); i++) {
            final String itemStr = jsonArr.getString(i);
            final TextView textView = new TextView(context);
            textView.setText(itemStr);
            textView.setTextSize(15);
            try {
                XmlPullParser xrp = context.getResources().getXml(R.drawable.menu_msg_text_color);
                textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp));
            } catch (Exception e) {
                e.printStackTrace();
            }
            textView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ((ChatActivity) context).sendText(itemStr);
                }
            });
            LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            llLp.bottomMargin = DensityUtil.dip2px(context, 3);
            llLp.topMargin = DensityUtil.dip2px(context, 3);
            parentView.addView(textView, llLp);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:uf.edu.encDetailActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.encdetail_activity);
    context = this.getApplicationContext();
    TextView tv = null;
    SeekBar sb = null;//from w  w w  . j ava 2 s . c o m
    Button b = null;
    Bundle bundle = this.getIntent().getExtras();
    Log.i("TAG", "encDetailActivity:onCreate,  Max Trust =" + getString(R.string.TrustSliderMax));
    MaxTrust = Integer.parseInt(getString(R.string.TrustSliderMax)) / 2;

    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                //Okay clicked.
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                //No button clicked
                break;
            }
        }
    };

    //builder.setMessage("Are you sure?").setPositiveButton("Okay", dialogClickListener);

    final EncUser encUser = (EncUser) bundle.getSerializable("userdata");
    final ArrayList<String> Address = (ArrayList<String>) bundle.getSerializable("useraddress");
    if (encUser == null) {
        Log.i(TAG, "encDetailsActivity: parameter received was null");
    }
    //Name
    tv = (TextView) findViewById(R.id.encdetail_name);
    tv.setText(encUser.Name);
    //Mac
    tv = (TextView) findViewById(R.id.encdetail_mac);
    tv.setText(encUser.Mac);
    tv.setOnClickListener(new View.OnClickListener() { //event listener to fetch more info abt a user.
        @Override
        public void onClick(View v) {
            iTrust.cd.write("Registration Lookup requested for " + encUser.Mac);
            Toast.makeText(encDetailActivity.this, "Please wait while we lookup the information",
                    Toast.LENGTH_LONG).show();
            String data = getData(encUser.Mac).replace('\n', ' ').trim();
            String message = null;
            if (data.substring(0, 5).compareToIgnoreCase("Error") == 0) {
                message = "No more info available for this device";
            } else {
                data = data.replace('\'', ' '); //remove single quotes
                data = data.replace(')', ' ').trim(); //remove closing brackets.
                StringTokenizer tok = new StringTokenizer(data.substring(1), ",");
                message = "Name: " + tok.nextToken() + " " + tok.nextToken() + "\n" + "Email: "
                        + tok.nextToken() + "\n" + "Profile: " + tok.nextToken();
            }
            //Toast.makeText(encDetailActivity.this, getData(encUser.Mac), Toast.LENGTH_LONG).show();
            builder.setMessage(message);
            builder.show();
        }
    });
    //lasttime
    tv = (TextView) findViewById(R.id.encdetail_lasttime);
    tv.setText((new java.util.Date((long) encUser.lastEncounterTime * 1000)).toString());
    tv.setOnClickListener(new View.OnClickListener() { //To generate graph
        @Override
        public void onClick(View v) {
            Intent intent = barchartIntent(encUser.timeSeries, encUser.Mac, encUser.Name);
            startActivity(intent);
        }
    });

    //tv.setText(Integer.toString(encUser.lastEncounterTime)); 
    //FE
    tv = (TextView) findViewById(R.id.encdetail_FE);
    tv.setText(Float.toString(encUser.score[0]));
    tv = (TextView) findViewById(R.id.encdetail_decayFE);
    tv.setText(Float.toString(encUser.decayScore[0] * ((float) Math.pow(.5,
            (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime)
                    / (float) 15552000.0F))));
    //DE
    tv = (TextView) findViewById(R.id.encdetail_DE);
    tv.setText(Float.toString(encUser.score[1]));
    tv = (TextView) findViewById(R.id.encdetail_decayDE);
    tv.setText(Float.toString(encUser.decayScore[1] * ((float) Math.pow(.5,
            (float) (((float) System.currentTimeMillis() / 1000) - (float) encUser.lastEncounterTime)
                    / (float) 15552000.0F))));
    //LV-C
    tv = (TextView) findViewById(R.id.encdetail_LVC);
    tv.setText(Float.toString(encUser.score[2]));
    //LV-D
    tv = (TextView) findViewById(R.id.encdetail_LVD);
    tv.setText(Float.toString(encUser.score[3]));
    //combined 
    //FE
    tv = (TextView) findViewById(R.id.encdetail_comb);
    tv.setText(Float.toString(encUser.score[4]));

    //check the toggle button state

    sb = (SeekBar) findViewById(R.id.encdetail_trust);
    //since Seekbar cannot go into -ve values we scale -Max Value to Max Value
    sb.setProgress(encUser.trusted + MaxTrust);
    tv = (TextView) findViewById(R.id.CurrentTrustValue);
    tv.setText(TrustArray[encUser.trusted + MaxTrust]);

    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        TextView tvcurrent = (TextView) findViewById(R.id.CurrentTrustValue);

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser == true) {
                Log.i(TAG, "encDetailsActivity: User changed value for Trust to " + progress);
                encUser.trusted = progress - MaxTrust;
                tvcurrent.setText(TrustArray[progress]);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }
    });

    b = (Button) findViewById(R.id.encdetail_done);
    b.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            iTrust.cd.write("Trust Value changed for this user :" + encUser.Mac + " to:" + encUser.trusted);
            Bundle bundle = new Bundle();
            Intent returnIntent = new Intent();
            bundle.putSerializable("Object", encUser);
            returnIntent.putExtras(bundle);
            //returnIntent.putExtra("TrustSet",trustResult);
            encDetailActivity.this.setResult(Activity.RESULT_OK, returnIntent);
            finish();
        }
    });

    //show map
    tv = (TextView) findViewById(R.id.encdetail_map);
    tv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            iTrust.cd.write("Map lookup for encounter user " + encUser.Mac);
            Bundle bundle = new Bundle();
            Intent newIntent = new Intent(context, map.class);
            bundle.putSerializable("useraddress", Address);
            newIntent.putExtras(bundle);
            startActivity(newIntent);
        }
    });

}

From source file:com.easemob.chatui.adapter.MessageAdapter.java

private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) {
    try {/*w w  w . ja  va  2  s . co  m*/
        parentView.removeAllViews();
        for (int i = 0; i < jsonArr.length(); i++) {
            final String itemStr = jsonArr.getString(i);
            final TextView textView = new TextView(context);
            textView.setText(itemStr);
            textView.setTextSize(15);
            try {
                XmlPullParser xrp = context.getResources().getXml(R.drawable.menu_msg_text_color);
                textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp));
            } catch (Exception e) {
                e.printStackTrace();
            }
            textView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    ((ChatActivity) context).sendText(itemStr);
                }
            });
            LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            llLp.bottomMargin = DensityUtil.dip2px(context, 3);
            llLp.topMargin = DensityUtil.dip2px(context, 3);
            parentView.addView(textView, llLp);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:com.saarang.samples.apps.iosched.ui.SessionDetailActivity.java

private void tryRenderTags() {
    if (mTagMetadata == null || mTagsString == null) {
        return;//ww w  .ja v  a  2  s . c  o  m
    }

    if (TextUtils.isEmpty(mTagsString)) {
        mTagsContainer.setVisibility(View.GONE);
    } else {
        mTagsContainer.setVisibility(View.VISIBLE);
        mTags.removeAllViews();
        LayoutInflater inflater = LayoutInflater.from(this);
        String[] tagIds = mTagsString.split(",");

        List<TagMetadata.Tag> tags = new ArrayList<TagMetadata.Tag>();
        for (String tagId : tagIds) {
            if (Config.Tags.SESSIONS.equals(tagId) || Config.Tags.SPECIAL_KEYNOTE.equals(tagId)) {
                continue;
            }

            TagMetadata.Tag tag = mTagMetadata.getTag(tagId);
            if (tag == null) {
                continue;
            }

            tags.add(tag);
        }

        if (tags.size() == 0) {
            mTagsContainer.setVisibility(View.GONE);
            return;
        }

        Collections.sort(tags, TagMetadata.TAG_DISPLAY_ORDER_COMPARATOR);

        for (final TagMetadata.Tag tag : tags) {
            TextView chipView = (TextView) inflater
                    .inflate(com.saarang.samples.apps.iosched.R.layout.include_session_tag_chip, mTags, false);
            chipView.setText(tag.getName());

            if (Config.Tags.CATEGORY_TOPIC.equals(tag.getCategory())) {
                ShapeDrawable colorDrawable = new ShapeDrawable(new OvalShape());
                colorDrawable.setIntrinsicWidth(mTagColorDotSize);
                colorDrawable.setIntrinsicHeight(mTagColorDotSize);
                colorDrawable.getPaint().setStyle(Paint.Style.FILL);
                chipView.setCompoundDrawablesWithIntrinsicBounds(colorDrawable, null, null, null);
                colorDrawable.getPaint().setColor(tag.getColor());
            }

            chipView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    finish(); // TODO: better encapsulation
                    Intent intent = new Intent(SessionDetailActivity.this, BrowseSessionsActivity.class)
                            .putExtra(BrowseSessionsActivity.EXTRA_FILTER_TAG, tag.getId())
                            .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            });

            mTags.addView(chipView);
        }
    }
}

From source file:dev.coatl.co.urband_basic.presenter.fragments.FragmentMenuPanel.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /* Initialize layout */
    View rootView = inflater.inflate(R.layout.fragment_menu_panel, null);

    VL1_skBr = (SeekBar) rootView.findViewById(R.id.VL1_skBr);
    VL2_skBr = (SeekBar) rootView.findViewById(R.id.VL2_skBr);
    RGBIntensity1_skBr = (SeekBar) rootView.findViewById(R.id.RGBIntensity1_skBr);
    RGBIntensity2_skBr = (SeekBar) rootView.findViewById(R.id.RGBIntensity2_skBr);

    seekBar1 = (SeekBar) rootView.findViewById(R.id.seekBar1);
    seekBar2 = (SeekBar) rootView.findViewById(R.id.seekBar2);
    seekBar3 = (SeekBar) rootView.findViewById(R.id.seekBar3);
    seekBar4 = (SeekBar) rootView.findViewById(R.id.seekBar4);
    seekBar5 = (SeekBar) rootView.findViewById(R.id.seekBar5);

    lv = (ListView) rootView.findViewById(R.id.log_console_LstView);
    arrayAdapter = new ArrayAdapter<>(this.getContext(), R.layout.simple_console_log, fruits_list);
    lv.setAdapter(arrayAdapter);//from   w w  w .j av  a2 s. c  o m

    final TextView mVL1_txtVw = (TextView) rootView.findViewById(R.id.VL1_txtVw);
    final TextView mVL2_txtVw = (TextView) rootView.findViewById(R.id.VL2_txtVw);
    final TextView mRGBIntensity1_txtVw = (TextView) rootView.findViewById(R.id.RGBIntensity1_txtVw);
    final TextView mRGBIntensity2_txtVw = (TextView) rootView.findViewById(R.id.RGBIntensity2_txtVw);

    final TextView textView1 = (TextView) rootView.findViewById(R.id.textView1);
    final TextView textView2 = (TextView) rootView.findViewById(R.id.textView2);
    final TextView textView3 = (TextView) rootView.findViewById(R.id.textView3);
    final TextView textView4 = (TextView) rootView.findViewById(R.id.textView4);
    final TextView textView5 = (TextView) rootView.findViewById(R.id.textView5);

    final TextView txtVwURBAND = (TextView) rootView.findViewById(R.id.txtVwURBAND);

    VL1_skBr.setProgress(0);
    VL2_skBr.setProgress(0);
    RGBIntensity1_skBr.setProgress(100);
    RGBIntensity2_skBr.setProgress(8);

    seekBar1.setProgress(100);
    seekBar2.setProgress(120);
    seekBar3.setProgress(140);
    seekBar4.setProgress(160);
    seekBar5.setProgress(180);

    int mProgress = VL1_skBr.getProgress();
    mVL1_txtVw.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = VL2_skBr.getProgress();
    mVL2_txtVw.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = RGBIntensity1_skBr.getProgress();
    mRGBIntensity1_txtVw.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = RGBIntensity2_skBr.getProgress();
    mRGBIntensity2_txtVw.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = seekBar1.getProgress();
    textView1.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = seekBar2.getProgress();
    textView2.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = seekBar3.getProgress();
    textView3.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = seekBar4.getProgress();
    textView4.setText(String.format(Locale.US, "%d", mProgress));

    mProgress = seekBar5.getProgress();
    textView5.setText(String.format(Locale.US, "%d", mProgress));

    txtVwURBAND.setOnClickListener(this);

    VL1_skBr.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            mVL1_txtVw.setText(Integer.toString(progress));
        }

    });

    VL2_skBr.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            mVL2_txtVw.setText(Integer.toString(progress));
        }

    });

    RGBIntensity1_skBr.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            mRGBIntensity1_txtVw.setText(Integer.toString(progress));
        }

    });

    RGBIntensity2_skBr.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            mRGBIntensity2_txtVw.setText(Integer.toString(progress));
        }

    });

    //set change listener
    final SeekBar.OnSeekBarChangeListener onSeekBarChangeListener1 = new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            DebugUtils.logInfo("onProgressChanged --- 1: " + Integer.toString(progress)
                    + " --------------------------------------------------------------");
            textView1.setText(Integer.toString(progress));
        }

    };

    seekBar1.setOnSeekBarChangeListener(onSeekBarChangeListener1);

    seekBar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            DebugUtils.logInfo("onProgressChanged ---- 2: " + Integer.toString(progress)
                    + " -------------------------------------------------------------");
            textView2.setText(Integer.toString(progress));
        }

    });

    seekBar3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            DebugUtils.logInfo("onProgressChanged --- 3: " + Integer.toString(progress)
                    + "--------------------------------------------------------------");
            textView3.setText(Integer.toString(progress));
        }

    });

    seekBar4.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            DebugUtils.logInfo("onProgressChanged ---- 4: " + Integer.toString(progress)
                    + " -------------------------------------------------------------");
            textView4.setText(Integer.toString(progress));
        }

    });

    seekBar5.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
            DebugUtils.logInfo("onProgressChanged 5: " + Integer.toString(progress)
                    + " -------------------------------------------------------------");
            textView5.setText(Integer.toString(progress));
        }

    });

    mActivity = getActivity();
    /*Returns generates view */
    return rootView;
}

From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java

private void setupScheduleEntrySpinners(final View entryView, ScheduleItem scheduleItem,
        String[] routineNames) {/*from   w w  w . j a  v a  2s  .  co  m*/

    final Spinner routineSpinner = (Spinner) entryView.findViewById(R.id.entry_routine_spinner);
    final TextView doseTv = (TextView) entryView.findViewById(R.id.entry_dose_textview);
    //        final Spinner doseSpinner = (Spinner) entryView.findViewById(R.id.entry_dose_spinner);

    doseTv.setTag(scheduleItem);
    routineSpinner.setTag(scheduleItem);

    // set up the routine selection adapter
    updateRoutineSelectionAdapter(entryView, routineSpinner, routineNames);

    if (scheduleItem != null && scheduleItem.routine() != null) {
        String routineName = scheduleItem.routine().name();
        int index = Arrays.asList(routineNames).indexOf(routineName);
        routineSpinner.setSelection(index);
    } else {
        routineSpinner.setSelection(routineNames.length - 1);
    }

    doseTv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDosePickerDialog((ScheduleItem) v.getTag(), (TextView) v);
        }
    });

    // set up the dose selection adapter
    //        ArrayAdapter<String> doseAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, doses);
    //        doseAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
    //        doseSpinner.setAdapter(doseAdapter);
    // select 1 pill by default
    //        doseSpinner.setSelection((int) scheduleItem.dose() - 1); // dose "1" is located at the index "0", and so on

    doseTv.setText(scheduleItem.displayDose());

    // setup listeners
    routineSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            String selected = (String) adapterView.getItemAtPosition(i);
            Routine r = Routine.findByName(selected);
            ScheduleItem item = ((ScheduleItem) routineSpinner.getTag());

            if (r != null) {
                updateEntryTime(r, entryView);
            } else {
                updateEntryTime(null, entryView);
                showAddNewRoutineDialog(entryView);
            }
            Log.d(TAG, "Updated routine to " + (r != null ? r.name() : "NULL") + " on item " + item.getId());
            item.setRoutine(r);

            logScheduleItems();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });

    routineSpinner.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_UP) {

                if (((String) routineSpinner.getSelectedItem())
                        .equalsIgnoreCase(getString(R.string.create_new_routine))) {
                    showAddNewRoutineDialog(entryView);
                    return true;
                }
            }
            return false;
        }
    });
}

From source file:com.quwu.xinwo.release.Release_Activity.java

/**
 * /*from  w ww .j  a  va  2s  .  c o m*/
 * PopupWindow
 * 
 * */
private void showPopupWindow(View view, final int i) {

    // 
    View contentView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.release_pop, null);

    final PopupWindow popupWindow = new PopupWindow(contentView, LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT, true);
    popupWindow.setOnDismissListener(new OnDismissListener() {

        public void onDismiss() {
            releaseLin.setAlpha(1f);
        }
    });
    popupWindow.setTouchable(true);

    popupWindow.setTouchInterceptor(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            return false;
            // true?touch
            // ? PopupWindowonTouchEvent?dismiss
        }
    });

    // ?PopupWindowBackdismiss
    // APIbug
    popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher));

    // ???show
    int[] location = new int[2];
    view.getLocationOnScreen(location);

    popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0] + view.getWidth(), location[1] - 150);

    // 
    TextView year = (TextView) contentView.findViewById(R.id.release_pop_yearText);
    year.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            handler.sendMessage(handler.obtainMessage(i, "/"));
            popupWindow.dismiss();
        }
    });
    TextView month = (TextView) contentView.findViewById(R.id.release_pop_monthText);
    month.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            handler.sendMessage(handler.obtainMessage(i, "/"));
            popupWindow.dismiss();
        }
    });
    TextView day = (TextView) contentView.findViewById(R.id.release_pop_dayText);
    day.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            handler.sendMessage(handler.obtainMessage(i, "/"));
            popupWindow.dismiss();
        }
    });
}

From source file:com.android.dialer.DialtactsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.e(TAG, " --- onCreate(Bundle savedInstanceState) ---  start ");
    Trace.beginSection(TAG + " onCreate");
    View retView = null;/*from w  ww . j  a  va  2s . c  om*/
    super.onCreateView(inflater, container, savedInstanceState);

    //??
    iControlDeleteBtn = (IControlDeleteBtn) getActivity();

    //mFirstLaunch = true;

    final Resources resources = getResources();
    int temp = resources.getDimensionPixelSize(R.dimen.floating_action_button_width);
    //?actionbar
    mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large);

    Trace.beginSection(TAG + " setContentView");
    //setContentView(R.layout.dialtacts_activity);
    retView = inflater.inflate(R.layout.dialtacts_activity, container, false);
    Trace.endSection();

    Trace.beginSection(TAG + " setup Views");
    final ActionBar actionBar = getActivity().getActionBar();
    //actionbar?
    //actionBar.setCustomView(R.layout.dialtacts_actionbar);
    //actionBar.setDisplayShowCustomEnabled(true);
    TextView actionbarNameTxt = (TextView) actionBar.getCustomView().findViewById(R.id.actionbar_name);
    actionbarNameTxt.setOnClickListener(this);
    ImageView actionbarMenu = (ImageView) actionBar.getCustomView().findViewById(R.id.actionbar_menu);
    actionbarMenu.setOnClickListener(this);
    TextView editerToCalldetail = (TextView) actionBar.getCustomView()
            .findViewById(R.id.actionbar_call_dialtacts_action_editer);
    editerToCalldetail.setOnClickListener(this);
    TextView cancelTxt = (TextView) actionBar.getCustomView()
            .findViewById(R.id.actionbar_call_dialtacts_action_cancel);
    cancelTxt.setOnClickListener(this);
    actionbarNameTxt.setText(getString(R.string.all_calls));
    mSearchView = (EditText) actionBar.getCustomView().findViewById(R.id.edittext);
    mSearchView.setVisibility(View.GONE);
    mDialtactsActionBarController = new DialtactsActionBarController(actionbarMenu, editerToCalldetail,
            cancelTxt, actionbarNameTxt, this);
    //        actionBar.setBackgroundDrawable(null);

    SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView()
            .findViewById(R.id.search_view_container);
    //        searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);

    //        mActionBarController = new DialtactsActionBarController(this, searchEditTextLayout);

    //        mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view);
    mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
    //        mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
    //        mSearchView.setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.findViewById(R.id.search_box_start_search)
    //                .setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener);
    //        searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() {
    //            @Override
    //            public void onBackButtonClicked() {
    //                onBackPressed();
    //            }
    //
    //            @Override
    //            public void onSearchViewClicked() {
    //                // Hide FAB, as the keyboard is shown.
    ////                mFloatingActionButtonController.scaleOut();
    //            }
    //        });
    mIsLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

    //        ImageButton optionsMenuButton =
    //                (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button);
    //        optionsMenuButton.setOnClickListener(this);
    //        mOverflowMenu = buildOptionsMenu(searchEditTextLayout);
    //        optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());

    // Add the favorites fragment but only if savedInstanceState is null. Otherwise the
    // fragment manager is responsible for recreating it.
    //???
    if (savedInstanceState == null) {
        getChildFragmentManager().beginTransaction()
                .add(R.id.dialtacts_container, new DialpadFragment(getActivity()), TAG_DIALPAD_FRAGMENT)
                //                   .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT)
                .commit();
    } else {
        mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
        mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
        mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
        mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
        mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
        //            mActionBarController.restoreInstanceState(savedInstanceState);
    }

    final boolean isLayoutRtl = DialerUtils.isRtl();
    //??????
    if (mIsLandscape) {
        //??
        mSlideIn = AnimationUtils.loadAnimation(getActivity(),
                isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right);
        mSlideOut = AnimationUtils.loadAnimation(getActivity(),
                isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right);
    } else {
        mSlideIn = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_in_bottom);
        mSlideOut = AnimationUtils.loadAnimation(getActivity(), R.anim.dialpad_slide_out_bottom);
    }

    //        mSlideIn.setInterpolator(AnimUtils.EASE_IN);
    mSlideOut.setInterpolator(AnimUtils.EASE_OUT);

    mSlideIn.setAnimationListener(mSlideInListener);
    mSlideOut.setAnimationListener(mSlideOutListener);

    Trace.endSection();

    Trace.beginSection(TAG + " initialize smart dialing");
    mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(getActivity());
    SmartDialPrefix.initializeNanpSettings(getActivity());
    Trace.endSection();
    Trace.endSection();
    initFlushHandler();

    Log.e(TAG, " onCreate()  dialerFragment  " + mIsDialpadShown);
    return retView;
}

From source file:cn.ucai.superwechat.adapter.MessageAdapter.java

@SuppressWarnings("ResourceType")
private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) {
    try {//from w ww .jav  a2s  .c  o m
        parentView.removeAllViews();
        for (int i = 0; i < jsonArr.length(); i++) {
            final String itemStr = jsonArr.getString(i);
            final TextView textView = new TextView(context);
            textView.setText(itemStr);
            textView.setTextSize(15);
            try {
                XmlPullParser xrp = context.getResources()
                        .getXml(cn.ucai.superwechat.R.drawable.menu_msg_text_color);
                textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp));
            } catch (Exception e) {
                e.printStackTrace();
            }
            textView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ((ChatActivity) context).sendText(itemStr);
                }
            });
            LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            llLp.bottomMargin = DensityUtil.dip2px(context, 3);
            llLp.topMargin = DensityUtil.dip2px(context, 3);
            parentView.addView(textView, llLp);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:com.shengtao.chat.chatUI.adapter.MessageAdapter.java

private void setRobotMenuMessageLayout(LinearLayout parentView, JSONArray jsonArr) {
    try {// w  w  w. j ava2 s  . c  om
        parentView.removeAllViews();
        for (int i = 0; i < jsonArr.length(); i++) {
            final String itemStr = jsonArr.getString(i);
            final TextView textView = new TextView(context);
            textView.setText(itemStr);
            textView.setTextSize(15);
            try {
                XmlPullParser xrp = context.getResources().getXml(drawable.menu_msg_text_color);
                textView.setTextColor(ColorStateList.createFromXml(context.getResources(), xrp));
            } catch (Exception e) {
                e.printStackTrace();
            }
            textView.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    ((ChatActivity) context).sendText(itemStr);
                }
            });
            LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            llLp.bottomMargin = DensityUtil.dip2px(context, 3);
            llLp.topMargin = DensityUtil.dip2px(context, 3);
            parentView.addView(textView, llLp);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

}