How To Find And Cast View Using Generic In Android

Suraj Bahadur
By -
0
private Button btnMakeObjectRequest, btnMakeArrayRequest;
private TextView txtResponse;

btnMakeArrayRequest = findViewByIdAndCast(R.id.btnArrayRequest);
btnMakeObjectRequest = findViewByIdAndCast(R.id.btnObjRequest);
txtResponse = findViewByIdAndCast(R.id.txtResponse);
@SuppressWarnings("uncheked")
private <T> T findViewByIdAndCast(int id) {
    return (T) findViewById(id);
}
Tags:

Post a Comment

0Comments

Post a Comment (0)