public UserTagView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @SuppressLint("InflateParams") LinearLayout cardView = (LinearLayout) LayoutInflater.from(context) .inflate(R.layout.layout_user_tag_view, null); avatarView = (CircleImageView) cardView.findViewById(R.id.user_avatar); userNameText = (TextView) cardView.findViewById(R.id.user_name); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, getResources().getDimensionPixelSize(R.dimen.user_tag_view_height)); this.addView(cardView, lp); cardView.setOnClickListener(view -> { if (mid != -1 && activity != null) { UserInfoDetailsActivity.launch(activity, name, mid, avatarUrl); } else if (onClickListener != null) { onClickListener.onClick(view); } }); }
View view = inflater.inflate(R.layout.fragment_a, null); persistentVariableEdit = (EditText) view.findViewById(R.id.editText); TextView proofTextView = (TextView) view.findViewById(R.id.textView); proofTextView.setText(persistentVariable); view.findViewById(R.id.btnPushFragmentB).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { public void onPause() { super.onPause(); String persistentVariable = persistentVariableEdit.getText().toString();
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_menu, container, false); final Button sendFreeTextButton = (Button) view.findViewById(R.id.sendFreeTextButton); sendFreeTextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.d(TAG, "sendFreeTextButton clicked"); Intent intent = new Intent(getActivity(), SendFreeTextActivity.class); MenuFragment.this.startActivity(intent); } }); ...
if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); RadioButton r = (RadioButton)v.findViewById(R.id.radiobutton); TextView tv = (TextView)v.findViewById(R.id.textview); tv.setText("Text view #" + position); RadioButton r = (RadioButton)v.findViewById(R.id.radiobutton); r.setChecked(position == selectedPosition); r.setTag(position); r.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) {
public class ViewDialog { public void showDialog(Activity activity, String msg){ final Dialog dialog = new Dialog(activity); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false); dialog.setContentView(R.layout.dialog); TextView text = (TextView) dialog.findViewById(R.id.text_dialog); text.setText(msg); Button dialogButton = (Button) dialog.findViewById(R.id.btn_dialog); dialogButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); View something = rootView.findViewById(R.id.something); // not activity findViewById() something.setOnClickListener(new View.OnClickListener() { ... }); return rootView; }
TextView txtName = (TextView) convertView.findViewById(R.id.nameEdit); txtName.setText(score.getName()); Button b = (Button)convertView.findViewById(R.id.deletePlayer); b.setTag(position); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) {
LayoutInflater infalInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.left_drawer_list_group, parent, false); .findViewById(R.id.left_menu_list_header_text); ImageView listHeaderArrow = (ImageView) convertView.findViewById(R.id.left_menu_list_header_arrow); listHeaderText.setText(headerTitle); listHeaderArrow.setImageResource(imageResourceId); listHeaderArrow.setOnClickListener(new View.OnClickListener() {
public class PresentActivity extends Activity { protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.content_layout_id); final Button button = (Button) findViewById(R.id.button_id); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click Intent activityChangeIntent = new Intent(PresentActivity.this, NextActivity.class); // currentContext.startActivity(activityChangeIntent); PresentActivity.this.startActivity(activityChangeIntent); } }); } }
row = mInflater.inflate(R.layout.custom_list_preference_row, parent, false); holder = new CustomHolder(row, position); row.setTag(holder); row.setOnClickListener(new View.OnClickListener() text.setText(entries[position]); rButton = (RadioButton)row.findViewById(R.id.custom_list_view_row_radio_button); rButton.setId(position); text.setTextColor(Color.LTGRAY); rButton.setClickable(false);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar ab = getSherlock().getActionBar(); LayoutInflater li = LayoutInflater.from(this); View customView = li.inflate(R.layout.my_custom_view, null); ab.setCustomView(customView); ImageButton ibItem1 = (ImageButton) customView.findViewById(R.id.item1); ibItem1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // ... } }); ImageButton ibItem2 = (ImageButton) customView.findViewById(R.id.item2); ibItem2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // ... } }); }
super.onCreate(savedInstanceState); btn_choose.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (requestCode == GALLERY_ACTIVITY_CODE) { if(resultCode == Activity.RESULT_OK){ picturePath = data.getStringExtra("picturePath"); Bundle extras = data.getExtras(); Bitmap selectedBitmap = extras.getParcelable("data"); Intent cropIntent = new Intent("com.android.camera.action.CROP");
Context context = container.getContext(); LinearLayout layout = new LinearLayout(context); buttonItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent("com.phone"); textItem.setText("First Screen"); break; case 1: textItem.setText("Second Screen"); break; case 2: textItem.setText("Third Screen"); break;
sherlockTitle.setVisibility(View.GONE); sherlockDivider.setVisibility(View.GONE); titleArea.setVisibility(View.VISIBLE); TextView titleView = (TextView) titleArea.findViewById(R.id.custom_title); if (titleView != null) { titleView.setText(R.string.tag_dialog_title); ImageButton cancelBtn = (ImageButton) titleArea.findViewById(R.id.cancel_btn); cancelBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ImageButton okBtn = (ImageButton) titleArea.findViewById(R.id.ok_btn); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
planet.toggleChecked(); ContactViewHolder viewHolder = (ContactViewHolder) item .getTag(); viewHolder.getCheckBox().setChecked(planet.isChecked()); convertView = inflater.inflate(R.layout.simplerow, null); .findViewById(R.id.rowTextView); checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01); checkBox.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v;
Intent intent = new Intent(this, DownloadingService.class); intent.putParcelableArrayListExtra("files", new ArrayList<File>(Arrays.asList(files))); startService(intent); bar.setProgress(file.progress); TextView tv = (TextView) v.findViewById(R.id.textView); tv.setText(file.toString()); v.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(); i.setAction(DownloadingService.ACTION_CANCEL_DOWNLOAD); i.putExtra(ID, file.getId()); Intent i = new Intent(); i.setAction(PROGRESS_UPDATE_ACTION); i.putExtra("position", positions);
@Override public void onCreate(Bundle savedInstanceState) { ... // Every time a button is clicked, we want to broadcast a notification. findViewById(R.id.button_send).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendMessage(); } }); } // Send an Intent with an action named "custom-event-name". The Intent sent should // be received by the ReceiverActivity. private void sendMessage() { Log.d("sender", "Broadcasting message"); Intent intent = new Intent("custom-event-name"); // You can also include some extra data. intent.putExtra("message", "This is my message!"); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
mMainMenuButton.setBackground(null); mMainMenuButton.setImageDrawable(menuIcon); mMainMenuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LayoutInflater inflater = getLayoutInflater(); View popupView = inflater.inflate(R.layout.menu_layout, null); VerticalLabelView menuItem1 = (VerticalLabelView)popupView.findViewById(R.id.menu_item1); menuItem1.setOnClickListener(mOnMenuItemClickListener); menuItem1.setText("Vertical menu item 1"); menuItem1.setTextSize(mTextSize); VerticalLabelView menuItem2 = (VerticalLabelView)popupView.findViewById(R.id.menu_item2); menuItem2.setOnClickListener(mOnMenuItemClickListener); menuItem2.setText("Vertical menu item 2"); menuItem2.setTextSize(mTextSize); VerticalLabelView menuItem3 = (VerticalLabelView)popupView.findViewById(R.id.menu_item3); menuItem3.setOnClickListener(mOnMenuItemClickListener); menuItem3.setText("Vertical menu item 3");
subLayout.setLayoutParams(params); topLayout.setOnTouchListener(new OnTouchListener() { buttonSwitch.setOnClickListener(new View.OnClickListener() { buttonSwitch.setClickable(false); topLayout.setEnabled(false); topLayout.layout(oldLeft, oldTop, oldLeft + topLayout.getMeasuredWidth(), oldTop + topLayout.getMeasuredHeight() ); menuOpen = false; buttonSwitch.setClickable(true); topLayout.setEnabled(true); } else if(menuOpen == false) {
View v = inflater.inflate(R.layout.player_password, container, false); passwordEdit = (EditText)v.findViewById(R.id.player_password_edit); okButton = (Button)v.findViewById(R.id.ok_button); okButton.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ passwordEntered(); playerListFragment.joinPlayer(toJoin, passwordEdit.getText().toString()); dismiss();