Search in sources :

Example 26 with ViewGroup

use of android.view.ViewGroup in project TextureViewDemo by dalinaum.

the class ListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    final Demo[] demos = { new Demo("Camera", CameraActivity.class), new Demo("GL Triangle", GLTriangleActivity.class), new Demo("Canvas", CanvasActivity.class), new Demo("Canvas2", Canvas2Activity.class), new Demo("Demo repository", null) };
    super.onCreate(savedInstanceState);
    final ListView listView = new ListView(this);
    listView.setAdapter(new ArrayAdapter<Demo>(this, R.layout.list, R.id.activity_name, demos) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final LinearLayout view = (LinearLayout) super.getView(position, convertView, parent);
            final Demo demo = getItem(position);
            final TextView activityClass = (TextView) view.findViewById(R.id.activity_class);
            if (demo.classType != null) {
                activityClass.setText(demo.classType.toString());
            } else {
                activityClass.setText("");
            }
            return view;
        }
    });
    listView.setClickable(true);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Demo demo = (Demo) parent.getAdapter().getItem(position);
            final Intent intent;
            if (demo.classType != null) {
                intent = new Intent(ListActivity.this, demo.classType);
            } else {
                final String url = "https://github.com/dalinaum/textureviewdemo";
                intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
            }
            startActivity(intent);
        }
    });
    setContentView(listView);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 27 with ViewGroup

use of android.view.ViewGroup in project MultipleTheme by dersoncheng.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btn = (ColorButton) findViewById(R.id.btn);
    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SharedPreferencesMgr.getInt("theme", 0) == 1) {
                SharedPreferencesMgr.setInt("theme", 0);
                setTheme(R.style.theme_1);
            } else {
                SharedPreferencesMgr.setInt("theme", 1);
                setTheme(R.style.theme_2);
            }
            final View rootView = getWindow().getDecorView();
            if (Build.VERSION.SDK_INT >= 14) {
                rootView.setDrawingCacheEnabled(true);
                rootView.buildDrawingCache(true);
                final Bitmap localBitmap = Bitmap.createBitmap(rootView.getDrawingCache());
                rootView.setDrawingCacheEnabled(false);
                if (null != localBitmap && rootView instanceof ViewGroup) {
                    final View localView2 = new View(getApplicationContext());
                    localView2.setBackgroundDrawable(new BitmapDrawable(getResources(), localBitmap));
                    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                    ((ViewGroup) rootView).addView(localView2, params);
                    localView2.animate().alpha(0).setDuration(400).setListener(new Animator.AnimatorListener() {

                        @Override
                        public void onAnimationStart(Animator animation) {
                            ColorUiUtil.changeTheme(rootView, getTheme());
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            ((ViewGroup) rootView).removeView(localView2);
                            localBitmap.recycle();
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animator animation) {
                        }
                    }).start();
                }
            } else {
                ColorUiUtil.changeTheme(rootView, getTheme());
            }
        }
    });
    btn_next = (ColorButton) findViewById(R.id.btn_2);
    btn_next.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, SecondActivity.class));
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) Intent(android.content.Intent) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View)

Example 28 with ViewGroup

use of android.view.ViewGroup in project MultipleTheme by dersoncheng.

the class ColorUiUtil method changeTheme.

/**
     * 切换应用主题
     *
     * @param rootView
     */
public static void changeTheme(View rootView, Resources.Theme theme) {
    if (rootView instanceof ColorUiInterface) {
        ((ColorUiInterface) rootView).setTheme(theme);
        if (rootView instanceof ViewGroup) {
            int count = ((ViewGroup) rootView).getChildCount();
            for (int i = 0; i < count; i++) {
                changeTheme(((ViewGroup) rootView).getChildAt(i), theme);
            }
        }
        if (rootView instanceof AbsListView) {
            try {
                Field localField = AbsListView.class.getDeclaredField("mRecycler");
                localField.setAccessible(true);
                Method localMethod = Class.forName("android.widget.AbsListView$RecycleBin").getDeclaredMethod("clear", new Class[0]);
                localMethod.setAccessible(true);
                localMethod.invoke(localField.get(rootView), new Object[0]);
            } catch (NoSuchFieldException e1) {
                e1.printStackTrace();
            } catch (ClassNotFoundException e2) {
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                e3.printStackTrace();
            } catch (IllegalAccessException e4) {
                e4.printStackTrace();
            } catch (InvocationTargetException e5) {
                e5.printStackTrace();
            }
        }
    } else {
        if (rootView instanceof ViewGroup) {
            int count = ((ViewGroup) rootView).getChildCount();
            for (int i = 0; i < count; i++) {
                changeTheme(((ViewGroup) rootView).getChildAt(i), theme);
            }
        }
        if (rootView instanceof AbsListView) {
            try {
                Field localField = AbsListView.class.getDeclaredField("mRecycler");
                localField.setAccessible(true);
                Method localMethod = Class.forName("android.widget.AbsListView$RecycleBin").getDeclaredMethod("clear", new Class[0]);
                localMethod.setAccessible(true);
                localMethod.invoke(localField.get(rootView), new Object[0]);
            } catch (NoSuchFieldException e1) {
                e1.printStackTrace();
            } catch (ClassNotFoundException e2) {
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                e3.printStackTrace();
            } catch (IllegalAccessException e4) {
                e4.printStackTrace();
            } catch (InvocationTargetException e5) {
                e5.printStackTrace();
            }
        }
    }
}
Also used : ColorUiInterface(derson.com.multipletheme.colorUi.ColorUiInterface) Field(java.lang.reflect.Field) ViewGroup(android.view.ViewGroup) AbsListView(android.widget.AbsListView) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 29 with ViewGroup

use of android.view.ViewGroup in project barcodescanner by dm77.

the class FullScannerActivity method onCreate.

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    if (state != null) {
        mFlash = state.getBoolean(FLASH_STATE, false);
        mAutoFocus = state.getBoolean(AUTO_FOCUS_STATE, true);
        mSelectedIndices = state.getIntegerArrayList(SELECTED_FORMATS);
        mCameraId = state.getInt(CAMERA_ID, -1);
    } else {
        mFlash = false;
        mAutoFocus = true;
        mSelectedIndices = null;
        mCameraId = -1;
    }
    setContentView(R.layout.activity_full_scanner);
    setupToolbar();
    ViewGroup contentFrame = (ViewGroup) findViewById(R.id.content_frame);
    mScannerView = new ZBarScannerView(this);
    setupFormats();
    contentFrame.addView(mScannerView);
}
Also used : ViewGroup(android.view.ViewGroup) ZBarScannerView(me.dm7.barcodescanner.zbar.ZBarScannerView)

Example 30 with ViewGroup

use of android.view.ViewGroup in project barcodescanner by dm77.

the class SimpleScannerActivity method onCreate.

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    setContentView(R.layout.activity_simple_scanner);
    setupToolbar();
    ViewGroup contentFrame = (ViewGroup) findViewById(R.id.content_frame);
    mScannerView = new ZBarScannerView(this);
    contentFrame.addView(mScannerView);
}
Also used : ViewGroup(android.view.ViewGroup) ZBarScannerView(me.dm7.barcodescanner.zbar.ZBarScannerView)

Aggregations

ViewGroup (android.view.ViewGroup)2280 View (android.view.View)1268 TextView (android.widget.TextView)439 ImageView (android.widget.ImageView)279 ArrayList (java.util.ArrayList)198 ViewParent (android.view.ViewParent)184 ListView (android.widget.ListView)156 Paint (android.graphics.Paint)125 FrameLayout (android.widget.FrameLayout)121 LayoutInflater (android.view.LayoutInflater)115 AdapterView (android.widget.AdapterView)115 LinearLayout (android.widget.LinearLayout)110 AbsListView (android.widget.AbsListView)106 Animator (android.animation.Animator)94 Drawable (android.graphics.drawable.Drawable)93 RecyclerView (android.support.v7.widget.RecyclerView)91 AnimatedView (carbon.animation.AnimatedView)88 ComponentView (carbon.component.ComponentView)88 RippleView (carbon.drawable.ripple.RippleView)88 ShadowView (carbon.shadow.ShadowView)88