Created
September 29, 2015 05:42
-
-
Save leasual/17c3c836f62b54eeb672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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