Friday 16 December 2016

How To Find And Cast View Using Generic In Android

  No comments
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);
}

No comments :

Post a Comment

Loading...