54 lines
1.5 KiB
Java
54 lines
1.5 KiB
Java
package de.marcelkapfer.morseconverter;
|
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.TextView;
|
|
|
|
/**
|
|
* Created by mmk on 3/30/15.
|
|
*/
|
|
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
|
|
private String[] mDataset;
|
|
|
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
|
// each data item is just a string in this case
|
|
public TextView mTextView;
|
|
public ViewHolder(View v) {
|
|
super(v);
|
|
mTextView = (TextView) v.findViewById(R.id.codefield);
|
|
}
|
|
|
|
public TextView getTextView() {
|
|
return mTextView;
|
|
}
|
|
}
|
|
|
|
public MyAdapter(String[] myDataset) {
|
|
mDataset = myDataset;
|
|
}
|
|
|
|
@Override
|
|
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
|
|
int viewType) {
|
|
// create a new view
|
|
View v = LayoutInflater.from(parent.getContext())
|
|
.inflate(R.layout.codeview, parent, false);
|
|
ViewHolder vh = new ViewHolder(v);
|
|
return vh;
|
|
}
|
|
|
|
// Replace the contents of a view (invoked by the layout manager)
|
|
@Override
|
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
|
holder.mTextView.setText(mDataset[position]);
|
|
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
return mDataset.length;
|
|
}
|
|
}
|