I have made an app in which i have an listView with JobCode and category.Now what i want to do is that when user click on a particular list item ,the full description on job should be displayed.But i dnt know hw to do it
Custom Adapter.Java
public class SearchJobsCustomList extends BaseAdapter implements View.OnClickListener {
Context c;
ArrayList<HashMap<String, String>> data;
HashMap<String, String> resultp = new HashMap<String, String> ();
// ArrayList<SearchValues> values;
// SearchValues a;
public SearchJobsCustomList(Context c, ArrayList<HashMap<String, String>> data) {
super ();
this.c = c;
this.data = data;
}
@Override
public int getCount() {
return data.size ();
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = LayoutInflater.from (c).inflate (R.layout.custom_search_jobs_lists, viewGroup, false);
resultp = data.get (i);
TextView JobCode = (TextView) view.findViewById (R.id.tv_job_code);
TextView Category = (TextView) view.findViewById (R.id.tv_category);
TextView ExpYrs = (TextView) view.findViewById (R.id.tv_exp_yrs);
TextView ExpMnths = (TextView) view.findViewById (R.id.tv_exp_mnths);
TextView Date = (TextView) view.findViewById (R.id.tv_date);
Button bestCandidate = (Button) view.findViewById (R.id.bt_best_candidates);
Button appliedJobs = (Button) view.findViewById (R.id.bt_applied_jobs);
if (resultp.get ("counts").equals (0)) {
bestCandidate.setFocusable (false);
bestCandidate.setText (0);
} else {
bestCandidate.setText (resultp.get ("counts"));
}
if (resultp.get ("applied").equals (0)) {
appliedJobs.setFocusable (false);
appliedJobs.setText (0);
} else {
appliedJobs.setText (resultp.get ("applied"));
}
JobCode.setText (resultp.get ("code"));
Category.setText (resultp.get ("category"));
ExpYrs.setText (resultp.get ("minExp"));
ExpMnths.setText (resultp.get ("maxExp"));
Date.setText (resultp.get ("postedOn"));
view.setOnClickListener (this);
}
return view;
}
SearchJobList.Java
public class SearchJobsList extends Activity implements AdapterView.OnItemClickListener {
private ListView lvresources;
private Context c = this;
SearchJobsCustomList searchJobsCustomList;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
getWindow ().requestFeature (Window.FEATURE_ACTION_BAR);
getActionBar ().hide ();
setContentView (R.layout.search_job_lists);
initialize ();
}
private void initialize() {
lvresources = (ListView) findViewById (R.id.listView);
searchJobsCustomList = new SearchJobsCustomList (c, SearchJobs.arraylist);
lvresources.setAdapter (searchJobsCustomList);
lvresources.setOnItemClickListener (this);
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
value = data.get (i);
Intent intent = new Intent (c, JobsDescription.class);
intent.putExtra ("code", value.get ("code"));
intent.putExtra ("category", value.get ("category"));
intent.putExtra ("position", value.get ("position"));
intent.putExtra ("desc", value.get ("desc"));
intent.putExtra ("type", value.get ("type"));
intent.putExtra ("hours", value.get ("hours"));
intent.putExtra ("status", value.get ("status"));
intent.putExtra ("expiryDate", value.get ("expiryDate"));
intent.putExtra ("address", value.get ("address"));
intent.putExtra ("state", value.get ("state"));
intent.putExtra ("country", value.get ("country"));
intent.putExtra ("city", value.get ("city"));
intent.putExtra ("gender", value.get ("gender"));
intent.putExtra ("religion", value.get ("religion"));
intent.putExtra ("summary", value.get ("summary"));
startActivity (intent);
}
}
The arraylist contains all the job details.