List of usage examples for android.widget ImageView setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityJourney.java
/** * sends a message to the driver of a journey *//*from w w w . ja v a 2 s . com*/ private void sendMessageToDriver() { final Dialog customDialog = new Dialog(this); customDialog.setContentView(R.layout.custom_dialog_layout); customDialog.setTitle("Message"); final List<String> spinnerArray = new ArrayList<String>(); spinnerArray.add("Everyone"); if (!getApp().getSelectedJourney().getDriver().equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getDriver().getFullName()); } for (int i = 0; i < getApp().getSelectedJourney().getHitchhikers().size(); i++) { if (!getApp().getSelectedJourney().getHitchhikers().get(i).equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getHitchhikers().get(i).getFullName()); } } final Spinner spinner = (Spinner) customDialog.findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(MapActivityJourney.this, android.R.layout.simple_spinner_item, spinnerArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); ImageView sendBtn = (ImageView) customDialog.findViewById(R.id.sendBtn); final EditText input = (EditText) customDialog.findViewById(R.id.input); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { User mid = getApp().getUser(); if (spinner.getSelectedItem().toString().equals("Everyone")) { if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { List<User> userList = new ArrayList<User>(); userList.add(getApp().getSelectedJourney().getDriver()); for (int k = 0; k < getApp().getSelectedJourney().getHitchhikers().size(); k++) { userList.add(getApp().getSelectedJourney().getHitchhikers().get(k)); } userList.remove(getApp().getUser()); for (int k = 0; k < userList.size(); k++) { sendMessage(userList.get(k), input); } Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } else { for (int j = 0; j < getApp().getSelectedJourney().getHitchhikers().size(); j++) { if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getHitchhikers().get(j).getFullName())) { mid = getApp().getSelectedJourney().getHitchhikers().get(j); } } if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getDriver().getFullName())) { mid = getApp().getSelectedJourney().getDriver(); } if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { sendMessage(mid, input); Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } } }); customDialog.show(); }
From source file:de.grobox.liberario.TripsActivity.java
private void addTrips(final TableLayout main, List<Trip> trip_list, boolean append) { if (trip_list != null) { // reverse order of trips if they should be prepended if (!append) { ArrayList<Trip> tempResults = new ArrayList<Trip>(trip_list); Collections.reverse(tempResults); trip_list = tempResults;// w ww . ja v a 2s. co m } for (final Trip trip : trip_list) { final LinearLayout trip_layout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.trip, null); TableRow row = (TableRow) trip_layout.findViewById(R.id.tripTableRow); // Locations TextView fromView = (TextView) row.findViewById(R.id.fromView); fromView.setText(trip.from.uniqueShortName()); TextView toView = ((TextView) row.findViewById(R.id.toView)); toView.setText(trip.to.uniqueShortName()); // Departure Time and Delay TextView departureTimeView = (TextView) row.findViewById(R.id.departureTimeView); TextView departureDelayView = (TextView) row.findViewById(R.id.departureDelayView); if (trip.getFirstPublicLeg() != null) { LiberarioUtils.setDepartureTimes(this, departureTimeView, departureDelayView, trip.getFirstPublicLeg().departureStop); } else { departureTimeView.setText(DateUtils.getTime(this, trip.getFirstDepartureTime())); } // Arrival Time and Delay TextView arrivalTimeView = (TextView) row.findViewById(R.id.arrivalTimeView); TextView arrivalDelayView = (TextView) row.findViewById(R.id.arrivalDelayView); if (trip.getLastPublicLeg() != null) { LiberarioUtils.setArrivalTimes(this, arrivalTimeView, arrivalDelayView, trip.getLastPublicLeg().arrivalStop); } else { arrivalTimeView.setText(DateUtils.getTime(this, trip.getLastArrivalTime())); } // Duration TextView durationView = (TextView) trip_layout.findViewById(R.id.durationView); durationView .setText(DateUtils.getDuration(trip.getFirstDepartureTime(), trip.getLastArrivalTime())); // Transports FlowLayout lineLayout = (FlowLayout) trip_layout.findViewById(R.id.lineLayout); // for each leg for (final Leg leg : trip.legs) { if (leg instanceof Trip.Public) { LiberarioUtils.addLineBox(this, lineLayout, ((Public) leg).line); } else if (leg instanceof Trip.Individual) { LiberarioUtils.addWalkingBox(this, lineLayout); } } // remember trip in view for onClick event trip_layout.setTag(trip); // make trip details fold out and in on click trip_layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View v = main.getChildAt(main.indexOfChild(view) + 1); if (v != null) { if (v.getVisibility() == View.GONE) { v.setVisibility(View.VISIBLE); } else if (v.getVisibility() == View.VISIBLE) { v.setVisibility(View.GONE); } } } }); trip_layout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { selectTrip(view, trip_layout); return true; } }); // show more button for trip details final ImageView showMoreView = (ImageView) trip_layout.findViewById(R.id.showMoreView); showMoreView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { selectTrip(view, trip_layout); } }); // Create container for trip details fragment FrameLayout fragmentContainer = new FrameLayout(this); fragmentContainer.setId(mContainerId); fragmentContainer.setVisibility(View.GONE); // Create a new Fragment to be placed in the activity layout TripDetailFragment tripDetailFragment = new TripDetailFragment(); // In case this activity was started with special instructions from an // Intent, pass the Intent's extras to the fragment as arguments Bundle bundle = new Bundle(); bundle.putSerializable("de.schildbach.pte.dto.Trip", trip); bundle.putSerializable("de.schildbach.pte.dto.Trip.from", from); bundle.putSerializable("de.schildbach.pte.dto.Trip.to", to); tripDetailFragment.setArguments(bundle); // Add the fragment to the 'fragment_container' FrameLayout getSupportFragmentManager().beginTransaction().add(mContainerId, tripDetailFragment).commit(); mContainerId++; if (append) { trip_layout.addView(LiberarioUtils.getDivider(this)); main.addView(trip_layout); main.addView(fragmentContainer); } else { trip_layout.addView(LiberarioUtils.getDivider(this), 0); main.addView(trip_layout, 0); main.addView(fragmentContainer, 1); } } // end foreach trip } else { // TODO offer option to query again for trips } }
From source file:com.mobicage.rogerthat.AbstractHomeActivity.java
private void initUI() { mBadgeMessages = (TextView) findViewById(R.id.badge_0x0); for (ItemDef i : getItemDefs()) { final ImageView icon = (ImageView) findViewById(i.iconId); icon.setOnClickListener(i.clickListener); final TextView label = (TextView) findViewById(i.labelId); label.setOnClickListener(i.clickListener); label.setText(i.labelTextId);//from w w w . j a va 2 s .c o m } loadQR(); }
From source file:com.shengtao.chat.chatUI.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from w w w . j a v a2 s. co m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = UIApplication.getContext().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:info.wncwaterfalls.app.InformationListFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (cursor.moveToFirst()) { String name = cursor.getString(AttrDatabase.COLUMNS.indexOf("name")); // Update the Activity's title getActivity().setTitle(name);/*www . j av a 2 s . c o m*/ // Load up the views // First load the image view by using the ImageLoader class // Determine the photo's file name mWaterfallId = cursor.getLong(AttrDatabase.COLUMNS.indexOf("_id")); mWaterfallName = cursor.getString(AttrDatabase.COLUMNS.indexOf("name")); String fileName = cursor.getString(AttrDatabase.COLUMNS.indexOf("photo_filename")); String[] fnParts = fileName.split("\\.(?=[^\\.]+$)"); final String image_fn = fnParts[0]; final String wf_name = mWaterfallName; final Long wf_id = mWaterfallId; // Display image in the image view. ImageView mainImageContainer = (ImageView) getView().findViewById(R.id.information_waterfall_image); mImgLoader.displayImage(fnParts[0], mainImageContainer, getActivity(), mImageHeight, mImageHeight); // Add click listener for fullscreen view mainImageContainer.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent fullScreenIntent = new Intent(v.getContext(), FullScreenImageActivity.class); fullScreenIntent.putExtra(IMAGE_FN, image_fn); fullScreenIntent.putExtra(WF_NAME, wf_name); fullScreenIntent.putExtra(WF_ID, wf_id); InformationListFragment.this.startActivity(fullScreenIntent); } }); // Next load the text view containing attributes. TextView description = (TextView) getView().findViewById(R.id.information_content_description); description.setText( Html.fromHtml(cursor.getString(AttrDatabase.COLUMNS.indexOf("description"))).toString()); // Prefix, db key, suffix String[][] hikeDetailElements = new String[][] { new String[] { " ", "trail_difficulty", "" }, new String[] { " ", "trail_tread", "" }, new String[] { " ", "trail_climb", "" }, new String[] { " Length: ", "trail_length", " mi" }, new String[] { " Lowest Elevation: ", "trail_elevationlow", " ft" }, new String[] { " Highest Elevation: ", "trail_elevationhigh", " ft" }, new String[] { " Total Climb: ", "trail_elevationgain", " ft" }, new String[] { " Configuration: ", "trail_configuration", "" } }; // Filter out blank values in the db ArrayList<String> hikeDetailList = new ArrayList<String>(); for (String[] element : hikeDetailElements) { String elementValue = cursor.getString(AttrDatabase.COLUMNS.indexOf(element[1])); if (elementValue != null && elementValue.length() > 0) { hikeDetailList.add(element[0] + elementValue + element[2]); } } // Stringifiy the ones that made it through String hikeDetailTxt = TextUtils.join("\n", hikeDetailList); TextView hikeDetails = (TextView) getView().findViewById(R.id.information_content_hike_details); hikeDetails.setText(hikeDetailTxt); TextView hikeDescription = (TextView) getView().findViewById(R.id.information_content_hike_description); hikeDescription.setText( Html.fromHtml(cursor.getString(AttrDatabase.COLUMNS.indexOf("trail_directions"))).toString()); // Repeat for waterfall attributes... String[][] detailElements = new String[][] { new String[] { " Height: ", "height", "" }, new String[] { " Stream: ", "stream", "" }, new String[] { " Landowner: ", "landowner", "" }, new String[] { " Bottom Elevation: ", "elevation", " ft" } }; // Filter out blank values in the db ArrayList<String> detailList = new ArrayList<String>(); for (String[] element : detailElements) { String elementValue = cursor.getString(AttrDatabase.COLUMNS.indexOf(element[1])); if (elementValue != null && elementValue.length() > 0) { detailList.add(element[0] + elementValue + element[2]); } } String detailTxt = TextUtils.join("\n", detailList); TextView waterfallDetails = (TextView) getView().findViewById(R.id.information_content_details); waterfallDetails.setText(detailTxt); TextView drivingDirections = (TextView) getView().findViewById(R.id.information_content_directions); drivingDirections.setText( Html.fromHtml(cursor.getString(AttrDatabase.COLUMNS.indexOf("directions"))).toString()); setupShareIntent(); // In case the options menu is already created } }
From source file:com.aprz.easy_iosched.ui.widget.CustomRatingBar.java
/** * Creates ({@link ImageView}s) used to submit a rating using unfilled drawables and adds them to * the layout.//from ww w . j a va 2 s. co m */ private void createRatingViews() { for (int i = 0; i < mMaxRating; i++) { ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams( new android.view.ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int tagValue = i + 1; imageView.setTag(tagValue); imageView.setContentDescription(getContext().getString(R.string.feedback_rating_value, tagValue)); imageView.setImageDrawable(mUnfilledDrawable); imageView.setOnClickListener(this); addView(imageView); } }
From source file:com.xogrp.planner.fragment.PortfolioSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_portfolio_images_slide_page, container, false);/*from w ww .j a va 2s . c o m*/ ImageView ivImage = (ImageView) rootView.findViewById(R.id.iv_pic); RelativeLayout rlPlay = (RelativeLayout) rootView.findViewById(R.id.rl_play); rlPlay.setVisibility(mMediaItem.getMediaType().equalsIgnoreCase(MEDIA_TYPE) ? View.VISIBLE : View.GONE); String imageUrl = mMediaItem.getMediaType().equalsIgnoreCase(MEDIA_TYPE) ? mMediaItem.getThumbnailUrl() : mMediaItem.getVideoUrl(); ImageLoader.getInstance().displayImage(imageUrl, ivImage, PlannerApplication.getDefaultDisplayImageOptions(R.drawable.vendor_summary_item_bg_default), null); ivImage.setOnClickListener(mOnClickListener); return rootView; }
From source file:com.richtodd.android.quiltdesign.app.BlockEditActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_block_edit); getActionBar().setDisplayHomeAsUpEnabled(true); m_blockNameArgument = getIntent().getStringExtra(ARG_BLOCK_NAME); if (savedInstanceState != null) { m_saveAsBlockName = savedInstanceState.getString("saveAsBlockName"); m_theme = (Theme) savedInstanceState.getParcelable("theme"); }/*w w w .j a v a2 s . c o m*/ ActionBar ab = getActionBar(); ab.setTitle("Edit Block"); ab.setSubtitle(getCurrentBlockName()); FragmentManager fm = getFragmentManager(); // Create color settings fragment. { Fragment f = fm.findFragmentById(R.id.layout_blockEditFragment); if (f == null) { f = BlockEditFragment.create(m_blockNameArgument); fm.beginTransaction().add(R.id.layout_blockEditFragment, f).commit(); } } m_themeView = (ThemeView) findViewById(R.id.themeView); m_themeView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Swatch swatch = (Swatch) m_themeView.getItemAtPosition(position); BlockEditFragment fragment = getBlockEditFragment(); if (fragment != null) { fragment.setColor(swatch.getColor()); } } }); m_themeView.setTheme(m_theme); m_button_setColor = (Button) findViewById(R.id.button_setColor); m_button_setColor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { chooseColor(); } }); m_button_addPiece = (Button) findViewById(R.id.button_addPiece); m_button_addPiece.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BlockEditFragment fragment = getBlockEditFragment(); int color = fragment.getColor(); PaperPiecedBlockPiece piece = fragment.addPiece(color); onPieceSelected(fragment, piece); } }); m_button_deletePiece = (Button) findViewById(R.id.button_deletePiece); m_button_deletePiece.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BlockEditFragment fragment = getBlockEditFragment(); fragment.deletePiece(); onPieceSelected(fragment, null); } }); ImageView button_refreshTheme = (ImageView) findViewById(R.id.button_refreshTheme); button_refreshTheme.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { refreshTheme(); } }); ImageView button_selectTheme = (ImageView) findViewById(R.id.button_selectTheme); button_selectTheme.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { chooseTheme(); } }); }
From source file:com.sonymobile.dronecontrol.activity.MainActivity.java
private void prepareUI() { ImageView ivBebop = (ImageView) findViewById(R.id.iv_bebop); ivBebop.setOnClickListener(new OnClickListener() { @Override//from w ww .ja v a2 s. c o m public void onClick(View v) { if (mSetupGuideFragment != null && mSetupGuideFragment.isDetached() && (mDeviceToConnect == null)) { if (verifyWifi()) { connectToDevice(EnumDevices.BEBOP); } } } }); ImageView ivSumo = (ImageView) findViewById(R.id.iv_js); ivSumo.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mSetupGuideFragment != null && mSetupGuideFragment.isDetached() && (mDeviceToConnect == null)) { if (verifyWifi()) { connectToDevice(EnumDevices.JUMPINGSUMO); } } } }); ImageView ivSpider = (ImageView) findViewById(R.id.iv_rs); ivSpider.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mSetupGuideFragment != null && mSetupGuideFragment.isDetached() && (mDeviceToConnect == null)) { if (verifyBluetooth()) { connectToDevice(EnumDevices.MINIDRONE); } } } }); }
From source file:DetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); detector = new GestureDetector(this, new GalleryGestureDetector()); listener = new View.OnTouchListener() { @Override/*from w w w . j a va2 s. co m*/ public boolean onTouch(View v, MotionEvent event) { return detector.onTouchEvent(event); } }; ImageIndex = 0; detailImage = (ImageView) findViewById(R.id.detail_image); detailImage.setOnTouchListener(listener); TextView detailName = (TextView) findViewById(R.id.detail_name); TextView detailDistance = (TextView) findViewById(R.id.detail_distance); TextView detailText = (TextView) findViewById(R.id.detail_text); detailText.setMovementMethod(new ScrollingMovementMethod()); ImageView detailWebLink = (ImageView) findViewById(R.id.detail_web_link); int i = MainActivity.currentItem; Random n = new Random(); int m = n.nextInt((600 - 20) + 1) + 20; setTitle(getString(R.string.app_name) + " - " + MainData.nameArray[i]); detailImage.setImageResource(MainData.detailImageArray[i]); detailName.setText(MainData.nameArray[i]); detailDistance.setText(String.valueOf(m) + " miles"); detailText.setText(MainData.detailTextArray[i]); detailWebLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse(MainData.detailWebLink[MainActivity.currentItem])); startActivity(intent); } }); }