List of usage examples for android.view View View
public View(Context context)
From source file:com.tmall.wireless.tangram.BaseTangramEngine.java
public BaseTangramEngine(@NonNull final Context context, @NonNull final DataParser<T, C, L> dataParser, @NonNull final IAdapterBuilder<C, ?> adapterBuilder) { //noinspection ConstantConditions Preconditions.checkArgument(context != null, "context is null"); this.mContext = context; this.mLayoutManager = new VirtualLayoutManager(mContext); this.mLayoutManager.setLayoutViewFactory(new LayoutViewFactory() { @Override//w w w .j a va2s .c o m public View generateLayoutView(@NonNull Context context) { ImageView imageView = ImageUtils.createImageInstance(context); return imageView != null ? imageView : new View(context); } }); this.mDataParser = Preconditions.checkNotNull(dataParser, "dataParser in constructor should not be null"); this.mAdapterBuilder = Preconditions.checkNotNull(adapterBuilder, "adapterBuilder in constructor should not be null"); }
From source file:io.nuclei.cyto.ui.view.BottomSheetView.java
private void init(Context context) { ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mMinFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); mTouchSlop = viewConfiguration.getScaledTouchSlop(); setClickable(true);// ww w. j ava 2s .co m mBackground = new View(context); mBackground.setBackgroundColor(mBackgroundColor = DEFAULT_BACKGROUND_COLOR); mBackground.setLayoutParams( new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mBackground.setVisibility(GONE); mBackground.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if ((mState & STATE_MOVING) != STATE_MOVING) { if ((mState & STATE_LOCKED) == STATE_LOCKED) removeState(STATE_LOCKED); setState(STATE_CLOSED); } } }); addView(mBackground); FrameLayout content = new FrameLayout(context); content.setLayoutParams( new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); content.setMinimumHeight(1); content.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); content.setClickable(true); addView(content); mContent = content; mOffsetHelper = new ViewOffsetHelper(mContent); onPrepare(); }
From source file:com.citrus.sample.UIActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_ui); activity = this; app_name = getResources().getString(R.string.app_name); frameLayout = (FrameLayout) findViewById(R.id.container); fragmentManager = getSupportFragmentManager(); citrusClient = CitrusClient.getInstance(mContext); citrusClient.enableLog(Constants.enableLogging); initCitrusClient();/*from w w w .ja v a 2 s. c om*/ citrusClient.enableAutoOtpReading(true); citrusConfig = CitrusConfig.getInstance(); citrusConfig.setColorPrimary(Constants.colorPrimary); citrusConfig.setColorPrimaryDark(Constants.colorPrimaryDark); citrusConfig.setTextColorPrimary(Constants.textColor); citrusConfig.enableOneTapPayment(Constants.ENABLE_ONE_TAP_PAYMENT); showUI(); snackBarParent = new View(this); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, 200); layoutParams.gravity = Gravity.BOTTOM; snackBarParent.setLayoutParams(layoutParams); frameLayout.addView(snackBarParent); }
From source file:com.carlrice.reader.utils.UiUtils.java
static public void addEmptyFooterView(ListView listView, int dp) { View view = new View(listView.getContext()); view.setMinimumHeight(dpToPixel(dp)); view.setClickable(true);//from w ww. j a v a 2 s .c o m listView.addFooterView(view); }
From source file:de.domjos.schooltools.helper.Helper.java
public static View getRowView(Context context, ViewGroup parent, int layout) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (inflater != null) { return inflater.inflate(layout, parent, false); }//from w w w . j a v a 2s. c o m return new View(context); }
From source file:com.ugia.listmovingcontainer.fragment.BottomListMovingContainerFragment.java
/** * View binding/*from ww w . ja va2 s. c om*/ */ private void bindViews() { mShadow = (ImageView) getActivity().findViewById(R.id.shadow); mShadow.setVisibility(mEnableFX ? View.VISIBLE : View.GONE); mainView = (RelativeLayout) getActivity().findViewById(R.id.mainView); mBottomListViewContainer = (RelativeLayout) getActivity().findViewById(R.id.bottomListViewContainer); mMainListView = (ListView) getActivity().findViewById(R.id.mainListView); mFakeFooter = new View(getActivity()); }
From source file:cl.mmoscoso.geocomm.GeoCommMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_geo_comm_main); //this.textview_name_user = (TextView) findViewById(R.id.text_view_status); //this.button_myroutes = (Button) findViewById(R.id.button_myroutes); this.list_routes = (ListView) findViewById(R.id.list_routes); //locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, this); list_routes.setClickable(true);//w w w. j av a 2s . c o m list_routes.setOnItemClickListener(this); SharedPreferences preferences = getSharedPreferences("userInformation", MODE_PRIVATE); SharedPreferences.Editor edit = preferences.edit(); edit.putBoolean("is_login", false); edit.commit(); getRoutes(new View(this)); }
From source file:com.wanderingcan.persistentsearch.PersistentSearchView.java
@SuppressWarnings("deprecation") private void initialize(Context context, AttributeSet attrs, int defStyleAttr) { mNavIcon = new ImageButton(context); mEndIcon = new ImageButton(context); mSearchText = new EditText(context); mSearchMenuView = new SearchMenuView(context); mDivider = new View(context); mDivider.setVisibility(GONE);// w ww . j a v a 2 s. c o m mPresenter = new SearchMenuPresenter(context, new SearchMenuListener()); mSearchMenuView.setAdapter(mPresenter.mAdapter); mSearchMenuView.addItemDecoration(new DividerItemDecoration(context, attrs)); int[] attr = { android.R.attr.listDivider }; TypedArray ta = context.obtainStyledAttributes(attr); Drawable divider = ta.getDrawable(0); ta.recycle(); mOpened = false; mShowClearDrawable = false; mShowMenu = true; //Set up CardView setUseCompatPadding(true); setFocusable(true); setFocusableInTouchMode(true); //Set up TextView if (Build.VERSION.SDK_INT >= 16) { mSearchText.setBackground(null); mNavIcon.setBackground(null); mEndIcon.setBackground(null); mDivider.setBackground(divider); } else { mSearchText.setBackgroundDrawable(null); mNavIcon.setBackgroundDrawable(null); mEndIcon.setBackgroundDrawable(null); mDivider.setBackgroundDrawable(divider); } mSearchText.setSingleLine(); mHintVisible = false; mSearchText.setOnFocusChangeListener(new SearchFocusListener()); mSearchText.setOnEditorActionListener(new EditTextEditorAction()); mSearchText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); mSearchText.addTextChangedListener(new EditTextTextWatcher()); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PersistentSearchView, defStyleAttr, 0); Drawable drawable = a.getDrawable(R.styleable.PersistentSearchView_navSrc); setNavigationDrawable(drawable); mNavIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); mNavIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mIconListener != null) { mIconListener.OnNavigationIconClick(); } } }); drawable = a.getDrawable(R.styleable.PersistentSearchView_endSrc); setEndDrawable(drawable); mClearDrawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_action_cancel); mEndIcon.setScaleType(ImageView.ScaleType.FIT_CENTER); mEndIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mShowClearDrawable) { //Clears the text mSearchText.setText(EMPTY); } else { if (mIconListener != null) { mIconListener.OnEndIconClick(); } } } }); mHint = a.getText(R.styleable.PersistentSearchView_hint); mHintAlwaysVisible = a.getBoolean(R.styleable.PersistentSearchView_hintAlwaysActive, false); if (mHintAlwaysVisible) { mSearchText.setHint(mHint); } a.recycle(); Resources res = context.getResources(); int imageDimen = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_dimen); mImageMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_side_margin); int imageTopMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_image_top_margin); //Sets all of the locations of the views CardView.LayoutParams lpNav = generateDefaultLayoutParams(); lpNav.width = lpNav.height = imageDimen; CardView.LayoutParams lpEnd = (LayoutParams) generateLayoutParams(lpNav); lpNav.gravity = Gravity.START; lpEnd.gravity = Gravity.END; if (Build.VERSION.SDK_INT >= 17) { mNavIcon.setPaddingRelative(mImageMargin, imageTopMargin, mImageMargin / 2, imageTopMargin); mEndIcon.setPaddingRelative(mImageMargin / 2, imageTopMargin, mImageMargin, imageTopMargin); } else { mNavIcon.setPadding(mImageMargin, imageTopMargin, mImageMargin / 2, imageTopMargin); mEndIcon.setPadding(mImageMargin / 2, imageTopMargin, mImageMargin, imageTopMargin); } CardView.LayoutParams lpText = generateDefaultLayoutParams(); lpText.gravity = Gravity.TOP; lpText.height = lpNav.topMargin + lpNav.height; mTextMargin = res.getDimensionPixelSize(R.dimen.persistent_search_view_text_margin); if (Build.VERSION.SDK_INT >= 17) { lpText.setMarginStart(mTextMargin); lpText.setMarginEnd(mTextMargin); } else { lpText.leftMargin = lpText.rightMargin = mTextMargin; } lpText = setupSearchTextMargin(lpText); CardView.LayoutParams lpMenu = generateDefaultLayoutParams(); lpMenu.topMargin = lpNav.topMargin + lpNav.height; lpMenu.height = RecyclerView.LayoutParams.WRAP_CONTENT; CardView.LayoutParams lpDivider = generateDefaultLayoutParams(); if (divider != null) { lpDivider.height = divider.getIntrinsicHeight(); } lpDivider.topMargin = lpNav.topMargin + lpNav.height; //Adds the views to the PersistentSearchView addView(mNavIcon, lpNav); addView(mEndIcon, lpEnd); addView(mSearchText, lpText); addView(mSearchMenuView, lpMenu); addView(mDivider, lpDivider); }
From source file:eu.power_switch.gui.fragment.phone.PhoneTabFragment.java
private void showTutorial(int tabIndex) { ArrayList<View> views = new ArrayList<>(); tabLayout.findViewsWithText(views, customTabAdapter.getPageTitle(tabIndex), View.FIND_VIEWS_WITH_TEXT); View dummyView;/* ww w .j a va2 s .c om*/ if (views.size() > 0) { dummyView = views.get(0); } else { dummyView = new View(getContext()); } String showcaseKey = TutorialHelper.getPhoneTabKey(customTabAdapter.getPageTitle(tabIndex).toString()); String contentText; switch (tabIndex) { case PhoneConstants.CALL_TAB_INDEX: contentText = getString(R.string.tutorial__phone_call_explanation); break; case PhoneConstants.SMS_TAB_INDEX: contentText = getString(R.string.tutorial__phone_sms_explanation); break; default: return; } new MaterialShowcaseView.Builder(getActivity()).setTarget(dummyView).setUseAutoRadius(false) .setRadius(64 * 3).setDismissOnTouch(true).setDismissText(getString(R.string.tutorial__got_it)) .setContentText(contentText).singleUse(showcaseKey).setDelay(500).show(); }
From source file:com.csounds.examples.tests.MultiTouchXYActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .j a va2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); for (int i = 0; i < touchIds.length; i++) { touchIds[i] = -1; touchX[i] = -1; touchY[i] = -1; } /* File outputFile = new File(DIR_NAME); File outputDir = this.getCacheDir(); // context being the Activity pointer try { outputFile = File.createTempFile("temp", "txt", outputDir); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ContextWrapper cw = new ContextWrapper(this); File directory = cw.getExternalFilesDir(null); txtfile = new File(directory,"temp.txt"); */ multiTouchView = new View(this); setContentView(R.layout.multitouchxy); multiTouchView = (RelativeLayout) findViewById(R.id.multitouchxy); Button loadPresetButton = (Button) findViewById(R.id.load_button); this.createLoadListener(loadPresetButton); multiTouchView.setOnTouchListener(new OnTouchListener() { /* (non-Javadoc) * @see android.view.View.OnTouchListener#onTouch(android.view.View, android.view.MotionEvent) */ public boolean onTouch(View v, MotionEvent event) { final int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); int id = getTouchId(pointerId); if (id == -1) { id = getTouchIdAssignment(); if (id != -1) { touchIds[id] = pointerId; touchX[id] = event.getX(i) / multiTouchView.getWidth(); touchY[id] = 1 - (event.getY(i) / multiTouchView.getHeight()); //TODO calculte interval Y int a = Math.round(id / 440); System.out.println("y " + a); if (touchXPtr[id] != null) { //TODO swtich touchid Log.d("touchXtouchY", "touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id] + " multitouchview width " + multiTouchView.getWidth() + " multitouchview width " + multiTouchView.getHeight()); // get the key from the touch coordinates float[] touchArray = new float[2]; touchArray = evaluateTouchKey(touchX[id], touchY[id]); touchX[id] = touchArray[0]; touchY[id] = touchArray[1]; Log.d("touchXtouchY", "touchX[id]) " + touchX[id] + " touchY[id]) " + touchY[id]); touchXPtr[id].SetValue(0, touchX[id]); touchYPtr[id].SetValue(0, touchY[id]); csoundObj.sendScore(String.format("i1.%d 0 -2 %d", id, id)); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, a)); writeToFile(String.format( "i1.%d 0 -2 %d", id, a)); */ } } } break; case MotionEvent.ACTION_MOVE: for (int i = 0; i < event.getPointerCount(); i++) { int pointerId = event.getPointerId(i); int id = getTouchId(pointerId); if (id != -1) { touchX[id] = event.getX(i) / multiTouchView.getWidth(); touchY[id] = 1 - (event.getY(i) / multiTouchView.getHeight()); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, id)); writeToFile(String.format( "i1.%d 0 -2 %d", id, id)); */ } break; case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_UP: { int activePointerIndex = event.getActionIndex(); int pointerId = event.getPointerId(activePointerIndex); int id = getTouchId(pointerId); if (id != -1) { touchIds[id] = -1; csoundObj.sendScore(String.format("i-1.%d 0 0 %d", id, id)); } //write file /* System.out.println(String.format( "i1.%d 0 -2 %d", id, id)); writeToFile(String.format( "i1.%d 0 -2 %d", id, id)); */ } break; } return true; } }); setContentView(multiTouchView); String csd = getResourceFileAsString(R.raw.multitouch_xy_kx); File f = createTempFile(csd); csoundObj.addBinding(this); csoundObj.startCsound(f); }