Back to project page KeepMySecret.
The source code is released under:
GNU General Public License
If you think the Android project KeepMySecret listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package keepmysecretapp.app.com.keepmysecretapp.adapters; //w w w.j a v a 2s .co m import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import java.util.ArrayList; import keepmysecretapp.app.com.keepmysecretapp.R; import keepmysecretapp.app.com.keepmysecretapp.activities.presentation.EntryPresentActivity; import keepmysecretapp.app.com.keepmysecretapp.db.EntryType; import keepmysecretapp.app.com.keepmysecretapp.other.Constants; import keepmysecretapp.app.com.keepmysecretapp.types.ListEntry; public class GroupEntryAdapter extends BaseAdapter { private static ArrayList<ListEntry> listGroupEntries; private LayoutInflater mInflater; private Context context; public GroupEntryAdapter(Context groupsFragment, ArrayList groupList) { listGroupEntries = groupList; context = groupsFragment; mInflater = LayoutInflater.from(groupsFragment); } @Override public int getCount() { if (listGroupEntries != null) return listGroupEntries.size(); return 0; } @Override public Object getItem(int position) { if (listGroupEntries != null) return listGroupEntries.get(0); return null; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.entry_item, null); holder = new ViewHolder(); holder.name = (TextView) convertView.findViewById(R.id.textEntryName); holder.id = (TextView)convertView.findViewById(R.id.entry_id_hidden); holder.describe = (TextView)convertView.findViewById(R.id.entryDescribe); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.name.setText(listGroupEntries.get(position).getName()); holder.describe.setText(listGroupEntries.get(position).getDescribe()); holder.id.setText(listGroupEntries.get(position).getID() + ""); setGroupEntryListener(convertView, holder.name.getText().toString(), Integer.parseInt(holder.id.getText().toString())); return convertView; } private void setGroupEntryListener(View view, final String entryName, final int id) { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent toEntry = new Intent(context, EntryPresentActivity.class); toEntry.putExtra(Constants.ENTRY_TITLE, entryName); toEntry.putExtra(Constants.ENTRY_ID, id); toEntry.putExtra(Constants.ENTRY_TYPE, EntryType.DATA.toString()); context.startActivity(toEntry); } }); } public static class ViewHolder { TextView id; TextView name; TextView describe; } }