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
public interface OnClickListener { | |
void onClick(View v); | |
} |
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
public class MainActivity extends Activity implements OnClickListener { | |
... | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
... | |
button.setOnClickListener(this); | |
} | |
public void onClick(View v) { |
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
fun String.shortToast() { | |
Toast.makeText(App.context(), this, Toast.LENGTH_SHORT).show() | |
} |
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
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> { | |
... | |
private CallBackItemList mListener; | |
public MyAdapter(String[] myDataset, CallBackItemList listener) { | |
... | |
mListener = listener; | |
} |
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
public class MainActivity extends Activity implements MyAdapter.CallBackItemList{ | |
... | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
... | |
mAdapter = new MyAdapter(myDataset, this); | |
... |
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
class MyAdapter(val mDataset: Array<String>, | |
val itemClickListener: (String) -> Unit, | |
val itemClickButtonListener: (String) -> Unit) : | |
RecyclerView.Adapter<MyAdapter.ViewHolder>() { | |
... | |
class ViewHolder(var mView: View) : RecyclerView.ViewHolder(mView) { | |
fun bind(item: String, | |
itemClickListener: (String) -> Unit, |
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
class MainActivity : Activity() { | |
... | |
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
mAdapter = MyAdapter(myDataset, {onClickActionItemList(it)}, {onClickActionButtonItemList(it)}) | |
... | |
} |
OlderNewer