Skip to content

Instantly share code, notes, and snippets.

@leasual
Created September 29, 2015 05:42
Show Gist options
  • Save leasual/17c3c836f62b54eeb672 to your computer and use it in GitHub Desktop.
Save leasual/17c3c836f62b54eeb672 to your computer and use it in GitHub Desktop.
package com.geedroid.util;
import android.app.Activity;
import android.view.View;
/**
* Created by james.li on 2015/9/29.
* 继承此类,可以使用getView(R.id.test);找到对应的控件,无需在使用findviewbyid()
*/
public class BaseActivity extends Activity {
public final <E extends View> E getView(int id) {
try {
return (E) findViewById(id);
} catch (ClassCastException ex) {
LogUtil.e("Could not cast View to concrete class.");
throw ex;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment