List of usage examples for android.widget LinearLayout findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:dev.datvt.cloudtracks.sound_cloud.LocalTracksFragment.java
public void setUpListPlaylist() { menus = new ArrayList<>(); mm.removeAllViews();/* www. j ava 2 s . c o m*/ LayoutInflater lf = LayoutInflater.from(ctx); if (true) { LinearLayout con; con = (LinearLayout) lf.inflate(R.layout.fragment_local_main, null); ImageView art = (ImageView) con.findViewById(R.id.artM); ImageView shuf = (ImageView) con.findViewById(R.id.shuffleM); ImageView del = (ImageView) con.findViewById(R.id.delM); TextView mn = (TextView) con.findViewById(R.id.nameM); TextView sn = (TextView) con.findViewById(R.id.noM); con.setGravity(Gravity.CENTER); art.setImageResource(R.drawable.icon_add_press); mn.setText(getString(R.string.create_new)); art.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showChangeLangDialog(); } }); mm.addView(con); } final ArrayList<String> names = ToolsHelper.getListPlaylist(); if (names.size() > 0) { for (int i = 0; i < ToolsHelper.getListPlaylist().size(); i++) { View con; con = lf.inflate(R.layout.fragment_local_main, null); ImageView art = (ImageView) con.findViewById(R.id.artM); ImageView shuf = (ImageView) con.findViewById(R.id.shuffleM); ImageView del = (ImageView) con.findViewById(R.id.delM); TextView mn = (TextView) con.findViewById(R.id.nameM); TextView sn = (TextView) con.findViewById(R.id.noM); Menu m; art.setImageResource(R.drawable.default_nhaccuatui); shuf.setImageResource(R.drawable.ic_shuffle); shuf.setVisibility(View.VISIBLE); del.setImageResource(R.drawable.ic_delete); del.setVisibility(View.VISIBLE); mn.setText(names.get(i).replace(".lst", "")); sn.setText( "" + ToolsHelper.getPlayList(ctx, names.get(i)).size() + " " + getString(R.string.songs)); sn.setVisibility(View.VISIBLE); final String playlistname = names.get(i); con.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mm.setVisibility(View.GONE); lnBack.setVisibility(View.VISIBLE); ref.setVisibility(View.VISIBLE); ExecuterU ex = new ExecuterU(ctx, getString(R.string.scanning)) { @Override public void doIt() { baseLocal = ToolsHelper.getPlayList(ctx, playlistname); } @Override public void doNe() { setUpList(baseLocal); } }; ex.execute(); } }); del.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { File f = new File(MainActivity.folder + "/Playlist/" + playlistname); f.delete(); setUpListPlaylist(); } }); shuf.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ExecuterU ex = new ExecuterU(ctx, getString(R.string.scanning)) { @Override public void doIt() { ArrayList<Track> tracks = ToolsHelper.getPlayList(ctx, playlistname); localTracks = tracks; } @Override public void doNe() { ArrayList<Track> tracks = localTracks; Collections.shuffle(tracks); if (tracks.size() > 0) { if (tracks.get(0).bpm == ToolsHelper.IS_LOCAL) mListener.onListFragmentInteraction(tracks, tracks.get(0), 0, ToolsHelper.IS_LOCAL); else { mListener.onListFragmentInteraction(tracks, tracks.get(0), 0, ToolsHelper.DOWNLOAD_CODE); } } else { ToolsHelper.toast(ctx, getString(R.string.empty_playlist)); } } }; ex.execute(); } }); m = new Menu(con, art, mn, sn); menus.add(m); mm.addView(con); } } }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
private void initImageMsgView(LinearLayout linearLayout) { String thumbPath = mCursor//from ww w . j ava 2 s . c o m .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL)); String fileName = mCursor .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.FILE_NAME)); thumbPath = RcsUtils.formatFilePathIfExisted(thumbPath); fileName = RcsUtils.formatFilePathIfExisted(fileName); ImageView imageView = (ImageView) linearLayout.findViewById(R.id.image_view); Bitmap thumbPathBitmap = null; Bitmap filePathBitmap = null; if (!TextUtils.isEmpty(thumbPath)) { thumbPathBitmap = RcsUtils.decodeInSampleSizeBitmap(thumbPath); } else if (!TextUtils.isEmpty(fileName)) { filePathBitmap = RcsUtils.decodeInSampleSizeBitmap(fileName); } if (thumbPathBitmap != null) { imageView.setBackgroundDrawable(new BitmapDrawable(thumbPathBitmap)); } else if (filePathBitmap != null) { imageView.setBackgroundDrawable(new BitmapDrawable(filePathBitmap)); } else { imageView.setBackgroundResource(R.drawable.ic_attach_picture_holo_light); } }
From source file:free.yhc.feeder.ChannelListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.channel_listview, null); mListView = (ListView) ll.findViewById(R.id.list); eAssert(null != mListView);// ww w . j a v a 2s . c o m mListView.setAdapter(new ChannelListAdapter(getActivity(), ChannelListAdapter.getQueryCursor(mCatId), mListView, DATA_REQ_SZ, DATA_ARR_MAX, new AdapterActionListener())); mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long itemId) { if (getAdapter().isLoadingItem(position)) return; Intent intent = new Intent(getActivity(), ItemListActivity.class); intent.putExtra(ItemListActivity.IKEY_MODE, ItemListActivity.MODE_CHANNEL); intent.putExtra(ItemListActivity.IKEY_FILTER, ItemListActivity.FILTER_NONE); intent.putExtra("cid", ((ChannelListAdapter) parent.getAdapter()).getItemInfo_cid(position)); startActivity(intent); } }); ScrollView sv = (ScrollView) ll.findViewById(R.id.empty_list); mListView.setEmptyView(sv); setToPrimary(mPrimary); return ll; }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
@Override public Object instantiateItem(ViewGroup view, int position) { mCursor.moveToPosition(position);/*from ww w . j a v a2 s. c o m*/ View content = mInflater.inflate(R.layout.message_detail_content, view, false); TextView bodyText = (TextView) content.findViewById(R.id.textViewBody); LinearLayout mLinearLayout = (LinearLayout) content.findViewById(R.id.other_type_layout); mMsgType = mCursor.getInt(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.MSG_TYPE)); if (mMsgType == RcsUtils.RCS_MSG_TYPE_TEXT) { initTextMsgView(bodyText); } else { bodyText.setVisibility(View.GONE); mLinearLayout.setVisibility(View.VISIBLE); ImageView imageView = (ImageView) mLinearLayout.findViewById(R.id.image_view); TextView textView = (TextView) mLinearLayout.findViewById(R.id.type_text_view); if (mMsgType != RcsUtils.RCS_MSG_TYPE_CAIYUNFILE) { imageView.setOnClickListener(mOnClickListener); } if (mMsgType == RcsUtils.RCS_MSG_TYPE_IMAGE) { initImageMsgView(mLinearLayout); showContentFileSize(textView); mContentType = "image/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_AUDIO) { imageView.setImageResource(R.drawable.rcs_voice); showContentFileSize(textView); mContentType = "audio/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VIDEO) { String thumbPath = mCursor.getString( mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL)); Bitmap bitmap = BitmapFactory.decodeFile(thumbPath); imageView.setImageBitmap(bitmap); showContentFileSize(textView); mContentType = "video/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_MAP) { imageView.setImageResource(R.drawable.rcs_map); String body = mCursor .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT)); textView.setText(body); mContentType = "map/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VCARD) { textView.setVisibility(View.GONE); initVcardMagView(mLinearLayout); mContentType = "text/x-vCard"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_PAID_EMO) { String messageBody = mCursor .getString(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.FILE_NAME)); String[] body = messageBody.split(","); RcsEmojiStoreUtil.getInstance().loadImageAsynById(imageView, body[0], RcsEmojiStoreUtil.EMO_STATIC_FILE); } else { bodyText.setVisibility(View.VISIBLE); mLinearLayout.setVisibility(View.GONE); initTextMsgView(bodyText); } } TextView detailsText = (TextView) content.findViewById(R.id.textViewDetails); detailsText.setText(getTextMessageDetails(mContext, mCursor, true)); view.addView(content); return content; }
From source file:com.purdue.CampusFeed.Activities.ContactDetailFragment.java
/** * Builds an address LinearLayout based on address information from the Contacts Provider. * Each address for the contact gets its own LinearLayout object; for example, if the contact * has three postal addresses, then 3 LinearLayouts are generated. * * @param addressType From// w w w. j a v a2 s . c om * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#TYPE} * @param addressTypeLabel From * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#LABEL} * @param address From * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#FORMATTED_ADDRESS} * @return A LinearLayout to add to the contact details layout, * populated with the provided address details. */ private LinearLayout buildAddressLayout(String contactPhoneNumber) { // Inflates the address layout final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.contact_detail_item, mDetailsLayout, false); // Gets handles to the view objects in the layout final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header); final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item); /* final ImageButton viewAddressButton = (ImageButton) addressLayout.findViewById(R.id.button_view_address); */ final ImageButton smsButton = (ImageButton) addressLayout.findViewById(R.id.contact_detail_item_sms_button); // http://stackoverflow.com/questions/1556987/how-to-make-a-phone-call-in-android-and-come-back-to-my-activity-when-the-call-i final String num = new String(contactPhoneNumber); this.contactPhoneNumber = contactPhoneNumber; smsButton.setOnClickListener(this); headerTextView.setText(contactPhoneNumber); addressTextView.setText(contactPhoneNumber); return addressLayout; }
From source file:org.matrix.console.activity.SettingsActivity.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_IMAGE) { if (resultCode == RESULT_OK) { this.runOnUiThread(new Runnable() { @Override/*ww w .j a va2 s . c o m*/ public void run() { final LinearLayout linearLayout = mLinearLayoutByMatrixId.get(mUpdatingSessionId); // sanity checks if (null != linearLayout) { ImageView avatarView = (ImageView) linearLayout.findViewById(R.id.imageView_avatar); Uri imageUri = data.getData(); Bitmap thumbnailBitmap = null; Uri scaledImageUri = data.getData(); try { ResourceUtils.Resource resource = ResourceUtils.openResource(SettingsActivity.this, imageUri); // with jpg files // check exif parameter and reduce image size if ("image/jpg".equals(resource.mimeType) || "image/jpeg".equals(resource.mimeType)) { InputStream stream = resource.contentStream; int rotationAngle = ImageUtils.getRotationAngleForBitmap(SettingsActivity.this, imageUri); String mediaUrl = ImageUtils.scaleAndRotateImage(SettingsActivity.this, stream, resource.mimeType, 1024, rotationAngle, SettingsActivity.this.mMediasCache); scaledImageUri = Uri.parse(mediaUrl); } else { ContentResolver resolver = getContentResolver(); List uriPath = imageUri.getPathSegments(); long imageId = -1; String lastSegment = (String) uriPath.get(uriPath.size() - 1); // > Kitkat if (lastSegment.startsWith("image:")) { lastSegment = lastSegment.substring("image:".length()); } imageId = Long.parseLong(lastSegment); thumbnailBitmap = MediaStore.Images.Thumbnails.getThumbnail(resolver, imageId, MediaStore.Images.Thumbnails.MINI_KIND, null); } resource.contentStream.close(); } catch (Exception e) { Log.e(LOG_TAG, "MediaStore.Images.Thumbnails.getThumbnail " + e.getMessage()); } if (null != thumbnailBitmap) { avatarView.setImageBitmap(thumbnailBitmap); } else { avatarView.setImageURI(scaledImageUri); } mTmpThumbnailUriByMatrixId.put(mUpdatingSessionId, scaledImageUri); final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save); saveButton.setEnabled(true); // Enable the save button if it wasn't already } } }); } mUpdatingSessionId = null; } }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void setContextButtonNormalMode(CommonLogFileListAdapter lfm_adapter) { final TextView dlg_title = (TextView) mDialog.findViewById(R.id.log_file_list_dlg_title); dlg_title.setText(mDialogTitle);//from w w w .j av a 2 s . com final ImageButton dlg_done = (ImageButton) mDialog.findViewById(R.id.log_file_list_dlg_done); dlg_done.setVisibility(ImageButton.GONE); LinearLayout ll_prof = (LinearLayout) mDialog.findViewById(R.id.log_context_view); LinearLayout ll_delete = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_delete_view); LinearLayout ll_share = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_share_view); LinearLayout ll_select_all = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_select_all_view); LinearLayout ll_unselect_all = (LinearLayout) ll_prof .findViewById(R.id.log_context_button_unselect_all_view); ll_delete.setVisibility(LinearLayout.GONE); ll_share.setVisibility(LinearLayout.GONE); if (lfm_adapter.isEmptyAdapter()) { ll_select_all.setVisibility(LinearLayout.GONE); ll_unselect_all.setVisibility(LinearLayout.GONE); } else { ll_select_all.setVisibility(LinearLayout.VISIBLE); ll_unselect_all.setVisibility(LinearLayout.GONE); } }
From source file:org.dpadgett.timer.WorldClockFragment.java
private void newClockDialog(final int position) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(context.getString(R.string.world_clock_select_timezone)); final Map<String, String> timezoneNameToId = new HashMap<String, String>(); final Set<Integer> timezones = new TreeSet<Integer>(); final Map<Integer, List<String>> offsetToName = new HashMap<Integer, List<String>>(); final long currentTime = System.currentTimeMillis(); for (final String timezone : TimeZone.getAvailableIDs()) { final TimeZone tz = TimeZone.getTimeZone(timezone); final boolean isDaylight = tz.useDaylightTime(); final String timezoneName = tz.getDisplayName(isDaylight, TimeZone.LONG, Locale.getDefault()); if (timezoneNameToId.containsKey(timezoneName)) { continue; }//from w w w . j a va2 s .c om final int millisOffset = tz.getOffset(currentTime); timezones.add(millisOffset); if (!offsetToName.containsKey(millisOffset)) { offsetToName.put(millisOffset, new ArrayList<String>()); } offsetToName.get(millisOffset).add(timezoneName); timezoneNameToId.put(timezoneName, timezone); } for (final List<String> names : offsetToName.values()) { Collections.sort(names); } if (position > -1) { builder.setPositiveButton(context.getString(R.string.world_clock_button_remove), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { clockList.remove(position); clocksListAdapter.notifyDataSetChanged(); final SharedPreferences.Editor prefs = context .getSharedPreferences("WorldClocks", Context.MODE_PRIVATE).edit(); prefs.putInt("numClocks", clockList.size()); int idx; for (idx = position; idx < clockList.size(); idx++) { prefs.putString("clock" + idx, clockList.get(idx)); } prefs.remove("clock" + idx); prefs.commit(); } }); } final LinearLayout tzView = (LinearLayout) LayoutInflater.from(context) .inflate(R.layout.timezone_picker_dialog, (ViewGroup) finder.findViewById(R.id.layout_root)); final List<String> initialItems = new ArrayList<String>(); initialItems.add(context.getString(R.string.world_clock_timezone_gmt)); initialItems.add(context.getString(R.string.world_clock_timezone_utc)); final ArrayAdapter<String> adapter = ArrayAdapter.newArrayAdapter(context, R.layout.timezone_dialog_list_item, initialItems); final ListView timezoneList = (ListView) tzView.findViewById(R.id.timezoneList); timezoneList.setAdapter(adapter); final TextView sliderView = (TextView) tzView.findViewById(R.id.timezoneLabel); final SeekBar timezoneSeeker = (SeekBar) tzView.findViewById(R.id.timezoneSeeker); final List<Integer> timezonesList = new ArrayList<Integer>(timezones); timezoneSeeker.setMax(timezonesList.size() - 1); if (position > -1) { final int offset = TimeZone.getTimeZone(clockList.get(position)).getOffset(currentTime); timezoneSeeker.setProgress(timezonesList.indexOf(offset)); } else { timezoneSeeker.setProgress(timezonesList.indexOf(0)); } timezoneSeeker.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { // initialize the timezoneSeeker { onProgressChanged(timezoneSeeker, timezoneSeeker.getProgress(), false); } @Override public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) { adapter.clear(); adapter.addAll(offsetToName.get(timezonesList.get(progress))); final int millisOffset = timezonesList.get(progress); String offset = String.format("%02d:%02d", Math.abs(millisOffset / 1000 / 60 / 60), Math.abs(millisOffset / 1000 / 60) % 60); if (millisOffset / 1000 / 60 / 60 < 0) { offset = "-" + offset; } else { offset = "+" + offset; } sliderView.setText(context.getString(R.string.world_clock_timezone_label) + offset); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { } @Override public void onStopTrackingTouch(final SeekBar seekBar) { } }); builder.setView(tzView); final AlertDialog alert = builder.create(); timezoneList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int selectedPosition, final long id) { final String timezoneName = adapter.getItem(selectedPosition); final String timezone = timezoneNameToId.get(timezoneName); addNewClock(timezone, position); alert.dismiss(); } }); alert.show(); }
From source file:com.qbgg.cenglaicengqu.common.ui.viewpager.PagerSlidingTabStrip.java
private void setChooseTabViewTextColor(int position) { int childCount = tabsContainer.getChildCount(); LinearLayout tabView; TextView textView;/*from w w w . ja va 2 s .co m*/ DisplayMetrics dm = getResources().getDisplayMetrics(); float value = value = dm.scaledDensity; int size = (int) getResources().getDimension(R.dimen.dimen_55px); for (int i = 0; i < childCount; ++i) { tabView = (LinearLayout) tabsContainer.getChildAt(i); textView = (TextView) tabView.findViewById(R.id.tab_title_label); textView.setTextSize(size / value); if (i == position) { textView.setTextColor(ContextCompat.getColor(getContext(), checkedTextColor)); } else { textView.setTextColor(ContextCompat.getColor(getContext(), unCheckedTextColor)); } } }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void setContextButtonSelecteMode(CommonLogFileListAdapter lfm_adapter) { final TextView dlg_title = (TextView) mDialog.findViewById(R.id.log_file_list_dlg_title); String sel = "" + lfm_adapter.getItemSelectedCount() + "/" + lfm_adapter.getCount(); dlg_title.setText(sel);// ww w. j ava2s .co m final ImageButton dlg_done = (ImageButton) mDialog.findViewById(R.id.log_file_list_dlg_done); dlg_done.setVisibility(ImageButton.VISIBLE); LinearLayout ll_prof = (LinearLayout) mDialog.findViewById(R.id.log_context_view); LinearLayout ll_delete = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_delete_view); LinearLayout ll_share = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_share_view); LinearLayout ll_select_all = (LinearLayout) ll_prof.findViewById(R.id.log_context_button_select_all_view); LinearLayout ll_unselect_all = (LinearLayout) ll_prof .findViewById(R.id.log_context_button_unselect_all_view); boolean deletable_log_selected = false; for (int i = 0; i < lfm_adapter.getCount(); i++) { if (lfm_adapter.getItem(i).isChecked && !lfm_adapter.getItem(i).isCurrentLogFile) { deletable_log_selected = true; break; } } if (deletable_log_selected) ll_delete.setVisibility(LinearLayout.VISIBLE); else ll_delete.setVisibility(LinearLayout.GONE); if (lfm_adapter.getItemSelectedCount() > 0) ll_share.setVisibility(LinearLayout.VISIBLE); else ll_share.setVisibility(LinearLayout.GONE); ll_select_all.setVisibility(LinearLayout.VISIBLE); if (lfm_adapter.isAnyItemSelected()) ll_unselect_all.setVisibility(LinearLayout.VISIBLE); else ll_unselect_all.setVisibility(LinearLayout.GONE); }