나는 JobCode 및 category.List와 함께 listView를 가지고 있으며, 사용자가 특정 목록 항목을 클릭하면 작업에 대한 전체 설명이 있어야합니다. displayed.But 내가 얼굴을가목록 열기에 대한 작업 세부 정보
사용자 정의 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);
}
}
ArrayList의 모든 작업의 세부 사항을 포함해야할지 DNT.
다른 활동을 사용하는 @Umar Saad 내 코드를 편집했지만 목록이 클릭되지 않음 – Anuj
'onClickListener'를'initialize()'함수에서 설정해보십시오. lvresources.setOnItemClickListener (새 OnItemClickListener() {public void onItemClick (AdapterView > adapterView, 뷰 뷰, int i, long l) {Log.d ("클릭 한 항목!", Integer.toString (i));} }});'LogCat을 사용하여 항목이 클릭되었는지 확인합니다. –
nw 클릭했지만 nw는 데이터의 크기 (ArrayList)로 0이됩니다. – Anuj