Java Code Examples for android.view.View#findViewById()

The following examples show how to use android.view.View#findViewById() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void showToast(Activity activity, String message, boolean vibrateLong) {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.custom_toast,
            activity.findViewById(R.id.custom_toast_container));

    TextView text = layout.findViewById(R.id.text);
    text.setText(message);

    Vibrator v = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
    if (vibrateLong) {
        v.vibrate(100);
        v.vibrate(200);
    } else {
        v.vibrate(100);
    }

    Toast toast = new Toast(activity.getApplicationContext());
    toast.setGravity(Gravity.BOTTOM, 0, convertDimensionToPx(this.getContext(), R.dimen.stdpadding));
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);
    toast.show();
}
 
Example 2
Source Project: weixin   File: AddressBookAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView != null) {
			holder = (ViewHolder) convertView.getTag();
		} else {
			convertView = View.inflate(mContext, R.layout.cgt_layout_addressbook_item, null);
			holder = new ViewHolder();
			holder.userPhoto = (ImageView) convertView.findViewById(R.id.cgt_iv_userPhoto);
			holder.userName = (TextView) convertView.findViewById(R.id.cgt_tv_userName);
			convertView.setTag(holder);
		}
		
//		holder.userPhoto.setImageResource(Integer.parseInt(mList.get(position).getUserPhote()));
		holder.userPhoto.setImageResource(R.drawable.icon);
		holder.userName.setText(mList.get(position).getUserAccount());
		return convertView;
	}
 
Example 3
Source Project: Bounce   File: ScrollViewFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_scroll_view, container, false);

    header = root.findViewById(R.id.header_image_view);
    scrollView = (ScrollView) root.findViewById(R.id.scroll_view);
    BounceTouchListener bounceTouchListener = BounceTouchListener.create(scrollView, R.id.content,
            new BounceTouchListener.OnTranslateListener() {
                @Override
                public void onTranslate(float translation) {
                    if (translation > 0) {
                        float scale = ((2 * translation) / header.getMeasuredHeight()) + 1;
                        header.setScaleX(scale);
                        header.setScaleY(scale);
                    }
                }
            }
    );

    scrollView.setOnTouchListener(bounceTouchListener);
    return root;
}
 
Example 4
@Override
public void doStatusSection() {
    View tempView = statusView.findViewById(R.id.water_heater_status_temp);

    tempBottomText = (TextView) tempView.findViewById(R.id.bottom_status_text);

    TextView tempTopText = (TextView) tempView.findViewById(R.id.top_status_text);
    tempTopText.setText("STANDARD");
    tempBottomText.setText("--");

    final ImageButton minusBtn = (ImageButton) statusView.findViewById(R.id.water_heater_minus_btn);
    ImageButton plusBtn = (ImageButton) statusView.findViewById(R.id.water_heater_plus_btn);
    ImageButton modeBtn = (ImageButton) statusView.findViewById(R.id.water_heater_mode_btn);

    minusBtn.setOnClickListener(this);
    plusBtn.setOnClickListener(this);
    modeBtn.setOnClickListener(this);

    WaterHeater device = getCapability(WaterHeater.class);
    MAX_HEAT_TEMP_VAL = MAX_HEAT_TEMP_DEFAULT;
    if (device != null) {
        if(device.getMaxsetpoint() != null) {
            MAX_HEAT_TEMP_VAL = TemperatureUtils.roundCelsiusToFahrenheit(device.getMaxsetpoint());
        }
        if(device.getSetpoint() != null) {
            int fahrenheit = TemperatureUtils.roundCelsiusToFahrenheit(device.getSetpoint());
            String fahrenheitString = fahrenheit + "º";
            tempBottomText.setText(fahrenheitString);
        }
        if(device instanceof AOSmithWaterHeaterController) {
            String mode = ((AOSmithWaterHeaterController)device).getControlmode();
            if(mode != null) {
                setMode(mode, false);
            }

        }
    }
}
 
Example 5
Source Project: CollapsingHeader   File: MainActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mFab = (FloatingActionButton)findViewById(R.id.favorite);
    mToolbar = (Toolbar)findViewById(R.id.toolbar);
    ListView listView = (ListView)findViewById(R.id.listview);

    if (mToolbar != null) {
        mToolbar.setTitle(getString(R.string.title));
        setSupportActionBar(mToolbar);
    }

    // Inflate the header view and attach it to the ListView
    View headerView = LayoutInflater.from(this)
                                    .inflate(R.layout.listview_header, listView, false);
    mContainerHeader = headerView.findViewById(R.id.container);
    listView.addHeaderView(headerView);

    // prepare the fade in/out animator
    fade =  ObjectAnimator.ofFloat(mContainerHeader, "alpha", 0f, 1f);
    fade.setInterpolator(new DecelerateInterpolator());
    fade.setDuration(400);

    listView.setOnScrollListener(this);
    listView.setAdapter(new ArrayAdapter<>(this,
                                    android.R.layout.simple_list_item_1,
                                    DUMMY_DATA));
}
 
Example 6
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.fragment_sub_recommended, container, false);
	mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_recommended_view);
	SubCategoryActivity activity = (SubCategoryActivity) this.getActivity();
	mPullToRefreshView.setOnHeaderRefreshListener(activity);
	mPullToRefreshView.setOnFooterRefreshListener(activity);
	ViewGroup parent = (ViewGroup) view.getParent();
	if (parent != null) {
		parent.removeView(view);
	}
	sub_recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_recommended_netWork_relativeLayout);

	mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_recommended_gridview);
	mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT));

	float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0);
	mPhotoWall.setColumnWidth((int) width);

	mPhotoWall.setOnItemClickListener(this);

	if (this.mShowNoNetworkView) {
		sub_recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE);
		mPullToRefreshView.setVisibility(View.GONE);
	} else {
		sub_recommendedNetWorkRelativeLayout.setVisibility(View.GONE);
		mPullToRefreshView.setVisibility(View.VISIBLE);
	}
	return view;
}
 
Example 7
Source Project: QSVideoPlayer   File: ListVideoActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void deactivate(View currentView, int position) {
    final DemoQSVideoView demoQSVideoView = (DemoQSVideoView) currentView.findViewById(R.id.qs);
    if (demoQSVideoView != null)
        demoQSVideoView.releaseInThread();
    Log.d("deactivate", "" + position);
}
 
Example 8
public ConfigurationSummaryHolder(View view) {
    super(view);
    mTotal = view.findViewById(R.id.total_value);
    view.findViewById(R.id.reset).setOnClickListener((View v) -> {
        new AlertDialog.Builder(v.getContext())
                .setTitle(R.string.pref_storage_reset_configuration)
                .setMessage(R.string.pref_storage_reset_configuration_confirm)
                .setPositiveButton(R.string.action_reset, (DialogInterface di, int i) -> {
                    new RemoveDataTask(v.getContext(), true, null).execute();
                })
                .setNegativeButton(R.string.action_cancel, null)
                .show();
    });
}
 
Example 9
Source Project: PTVGlass   File: SelectValueScrollAdapter.java    License: MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.card_select_value, parent);
    }

    final TextView view = (TextView) convertView.findViewById(R.id.value);
    view.setText(String.format("%02d", position));

    return setItemOnCard(this, convertView);
}
 
Example 10
Source Project: xmpp   File: LoginPagerAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object instantiateItem(View view, int position) {

	View arg0 = LayoutInflater.from(context).inflate(
			R.layout.login_viewpager_item, null);
	ImageView iv = (ImageView) arg0
			.findViewById(R.id.login_viewpageritem_img);

	iv.setBackgroundResource(img[position]);
	pager.addView(arg0);
	return arg0;
}
 
Example 11
Source Project: Klyph   File: GroupTimelineAdapter.java    License: MIT License 5 votes vote down vote up
@Override
protected void attachHolder(View view)
{
	ImageView elementCoverImage = (ImageView) view.findViewById(R.id.element_cover_image);
	ImageView elementProfileImage = (ImageView) view.findViewById(R.id.element_profile_image);
	TextView elementDetail1 = (TextView) view.findViewById(R.id.element_detail_1);
	TextView elementDetail2 = (TextView) view.findViewById(R.id.element_detail_2);
	TextView elementDetail3 = (TextView) view.findViewById(R.id.element_detail_3);
	TextView elementDetail4 = (TextView) view.findViewById(R.id.element_detail_4);
	TextView likes = (TextView) view.findViewById(R.id.likes);
	TextView talkAbout = (TextView) view.findViewById(R.id.talk_about);

	view.setTag(new ElementTimelineHolder(elementCoverImage, elementProfileImage, elementDetail1, elementDetail2,
			elementDetail3, elementDetail4, likes, talkAbout));
}
 
Example 12
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);
    final ImageView iconView = (ImageView) view.findViewById(R.id.icon);
    if (mMyIcon != null) {
        iconView.setImageDrawable(mMyIcon);
    } else {
        iconView.setVisibility(View.GONE);
    }
}
 
Example 13
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	super.onCreateView(inflater, container, savedInstanceState);
	View v = inflater.inflate(R.layout.fragment_persondetails, container, false);
	mName = (TextView)v.findViewById(R.id.persondetails_name);
	mStatus = (TextView)v.findViewById(R.id.persondetails_status);
	mEdit = (Button)v.findViewById(R.id.persondetails_edit);
	mReturned = (Button)v.findViewById(R.id.persondetails_returned);
	mPic = (RoundedImageView)v.findViewById(R.id.persondetails_pic);
	mEdit.setOnClickListener(this);
	mReturned.setOnClickListener(this);
	mItems = ((LoanHistoryActivity)getActivity()).getAllItems();
	updateInformation();
	return v;
}
 
Example 14
private void showPassword() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    final View view = getLayoutInflater().inflate(R.layout.dialog_show_password, null);
    final TextView password = view.findViewById(R.id.password);
    password.setText(mAccount.getPassword());
    builder.setTitle(R.string.password);
    builder.setView(view);
    builder.setPositiveButton(R.string.cancel, null);
    builder.create().show();
}
 
Example 15
public ItemViewHolder(View view) {
    super(view);
    textView = (TextView) view.findViewById(android.R.id.text1);
}
 
Example 16
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main_container);
	RootTools.debugMode = false;
	
	boolean access = RootTools.isAccessGiven();
	boolean busybox = RootTools.isBusyboxAvailable();
	if(!access) {
		showRootWarning();
	}
	if(!busybox) {
		showBusyBoxWarning();
	}
	
	mContainer = (FrameLayout) findViewById(R.id.activity_container);
	mContext = this;
	mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
	getActionBar().setDisplayHomeAsUpEnabled(true);
	getActionBar().setHomeButtonEnabled(true);
	View v = this.getLayoutInflater().inflate(R.layout.menu_list, null, false);
	menulist = (ListView) v.findViewById(R.id.navbarlist);
	db = new DatabaseHandler(this);
	vddDb = new VddDatabaseHandler(this);

	menu = new SlidingMenu(this);
	menu.setMode(SlidingMenu.LEFT_RIGHT);
	menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
	menu.setShadowWidthRes(R.dimen.shadow_width);
	menu.setShadowDrawable(R.drawable.shadow);
	//menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
	menu.setBehindWidthRes(R.dimen.slidingmenu_offset);
	menu.setFadeDegree(0.35f);
	menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
	menu.setMenu(v);
	View vv = this.getLayoutInflater().inflate(R.layout.menu_glossary, null, false);
	mGlossaryContainer = (FrameLayout) vv.findViewById(R.id.menu_frame);
	menu.setSecondaryMenu(vv);
	menu.setSecondaryShadowDrawable(R.drawable.shadow_right);

	mAdapter = new CustomArrayAdapter(
			this,
			R.layout.menu_main_list_item,
			getResources().getStringArray(R.array.menu_entries), 
			getResources().getStringArray(R.array.menu_descs),
			getResources().getStringArray(R.array.menu_colors),
			icons);
	menulist.setAdapter(mAdapter);
	menulist.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
	menulist.setOnItemClickListener(this);

	colors = getResources().getStringArray(R.array.menu_colors);

	FragmentTransaction ft = getFragmentManager().beginTransaction();
	Fragment prefs = new TimeInState();
	CpuGlossaryFragment glo = new CpuGlossaryFragment();
	ft.replace(R.id.activity_container,prefs);
	ft.replace(R.id.menu_frame, glo);
	ft.commit();

	
	setAppTheme();
	mountPartitions();
	copyHelpers();
}
 
Example 17
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRootView = view.findViewById(R.id.root_view);
    mBottomViewContainer = view.findViewById(R.id.bottom_container);

    //Set backspace button
    mBackSpaceBtn = view.findViewById(R.id.emojis_backspace);
    mBackSpaceBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view1) {
            if (mEmoticonSelectListener != null) mEmoticonSelectListener.onBackSpace();

            //dispatch back space event
            final KeyEvent event = new KeyEvent(0, 0, 0,
                    KeyEvent.KEYCODE_DEL, 0, 0, 0, 0,
                    KeyEvent.KEYCODE_ENDCALL);
            EmoticonGIFKeyboardFragment.this.getActivity().dispatchKeyEvent(event);
        }
    });

    //Set emoticon button
    mEmoticonTabBtn = view.findViewById(R.id.btn_emoji_tab);
    mEmoticonTabBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view12) {
            EmoticonGIFKeyboardFragment.this.replaceFragment(mEmoticonFragment, TAG_EMOTICON_FRAGMENT);
        }
    });
    mEmoticonTabBtn.setVisibility(isEmoticonsEnable() && isGIFsEnable() ? View.VISIBLE : View.GONE);

    //Set GIF button
    mGifTabBtn = view.findViewById(R.id.btn_gif_tab);
    mGifTabBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view13) {
            EmoticonGIFKeyboardFragment.this.replaceFragment(mGifFragment, TAG_GIF_FRAGMENT);
        }
    });
    mGifTabBtn.setVisibility(isEmoticonsEnable() && isGIFsEnable() ? View.VISIBLE : View.GONE);

    //Setup the search button.
    View searchBtn = view.findViewById(R.id.search_btn);
    searchBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view14) {
            if (mEmoticonTabBtn.isSelected()) {
                EmoticonGIFKeyboardFragment.this.replaceFragment(mEmoticonSearchFragment, TAG_EMOTICON_SEARCH_FRAGMENT);
            } else {
                EmoticonGIFKeyboardFragment.this.replaceFragment(mGifSearchFragment, TAG_GIF_SEARCH_FRAGMENT);
            }
        }
    });

    if (savedInstanceState != null) {   //Fragment reloaded from config changes,
        //noinspection ConstantConditions
        switch (savedInstanceState.getString(KEY_CURRENT_FRAGMENT)) {
            case TAG_EMOTICON_FRAGMENT:
                replaceFragment(mGifFragment, TAG_GIF_FRAGMENT);
                break;
            case TAG_GIF_FRAGMENT:
                replaceFragment(mEmoticonFragment, TAG_EMOTICON_FRAGMENT);
                break;
            case TAG_EMOTICON_SEARCH_FRAGMENT:
                replaceFragment(mEmoticonSearchFragment, TAG_EMOTICON_SEARCH_FRAGMENT);
                break;
            case TAG_GIF_SEARCH_FRAGMENT:
                replaceFragment(mGifSearchFragment, TAG_GIF_SEARCH_FRAGMENT);
                break;
        }
    } else {
        //Display emoticon fragment by default.
        if (isEmoticonsEnable())
            replaceFragment(mEmoticonFragment, TAG_EMOTICON_FRAGMENT);
        else if (isGIFsEnable())
            replaceFragment(mGifFragment, TAG_GIF_FRAGMENT);
        else
            throw new IllegalStateException("At least one of emoticon or GIF should be active.");
    }
}
 
Example 18
Source Project: open   File: RouteFragment.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.route_widget, container, false);
    ButterKnife.inject(this, rootView);
    fragment = this;
    adapter = new RouteAdapter(act, instructions, fragment);
    adapter.setDestinationName(simpleFeature.getProperty(TEXT));
    TextView destinationName = (TextView) rootView.findViewById(R.id.destination_name);
    destinationName.setText(getString(R.string.routing_to_text) + simpleFeature
            .getProperty(TEXT));
    if (route != null) {
        distanceToDestination.setDistance(route.getTotalDistance());
    }
    pager.setAdapter(adapter);
    pager.setOnPageChangeListener(this);
    adapter.notifyDataSetChanged();
    currentXCor = mapFragment.getMap().getMapPosition().getX();
    initSpeakerbox();
    initNotificationCreator();
    pager.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            turnAutoPageOff();
            return false;
        }
    });
    initDebugView(rootView);
    initSlideLayout(rootView);
    setMapOnTouchListener();

    res = act.getResources();
    prefs = getDefaultSharedPreferences(act);

    if (LocationServices.FusedLocationApi != null) {
        if (prefs.getBoolean(getString(R.string.settings_mock_gpx_key), false)) {
            final String key = getString(R.string.settings_mock_gpx_filename_key);
            final String defaultFile =
                    getString(R.string.settings_mock_gpx_filename_default_value);
            final String filename = prefs.getString(key, defaultFile);
            final File file = new File(Environment.getExternalStorageDirectory(),
                    filename);
            LocationServices.FusedLocationApi.setMockMode(true);
            LocationServices.FusedLocationApi.setMockTrace(file);
        } else {
            LocationServices.FusedLocationApi.setMockMode(false);
        }
    }

    hideLocateButtonAndAttribution();
    return rootView;
}
 
Example 19
@Override protected void assignViews(View itemView) {
  spinner = (Spinner) itemView.findViewById(R.id.comments_filter_language_spinner);
}
 
Example 20
public View getView(int position, View convertView,
										ViewGroup parent) {
	View row=convertView;
	
	if (row==null) {													
		LayoutInflater inflater=getLayoutInflater();
		
		row=inflater.inflate(R.layout.row2, parent, false);
	}
	
	TextView label=(TextView)row.findViewById(R.id.label);
	
	label.setText(array.get(position));
	
	return(row);
}