I always bump into these when I do method overloading. How can I write the 2nd method in one line? View.setText(text)
returns void
, but I want to return the TextView
after it executes setText()
.
Note: I know I can 'write it in two statments'. Question is asking how to make it in one.
private ViewGroup getExpanableListChild() {
return (LinearLayout) LayoutInflater.from(this).inflate(
R.layout.list_checkbox, null);
}
private ViewGroup getExpanableListChild(String text) {
return ViewUtil.getTextViewFromParent(getExpanableListChild()).setText(
text);//compile error, can't return void.
}