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);
}
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));
}
});
}
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();
}
}
}
}
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);
}
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);
}
Aggregations