private void initData() { selectedApps = new ArrayList<App>(); apps = ComplexPreferences.getObject( getApplicationContext(), Constants.ExistedApp, new TypeReference<ArrayList<App>>() {}); appsAdapter = new AppsAdapter(getApplicationContext()); lvApps.setAdapter(appsAdapter); }
public void initView() { lv = (MyListView) layout.findViewById(R.id.lv_circle_apps); lv.setAdapter(appsAdapter); }
private void initView() { mListView = (MyListView) findViewById(R.id.result_search_list); users = new ArrayList<User>(); title = (TextView) findViewById(R.id.txt_title); title.setText("添加好友"); cancel = (Button) findViewById(R.id.txt_left); cancel.setVisibility(View.VISIBLE); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub onBackPressed(); } }); search = (ClearEditText) findViewById(R.id.et_search_user); search.requestFocus(); search.setInputType(InputType.TYPE_CLASS_NUMBER); search.setOnEditorActionListener( new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub switch (actionId) { case EditorInfo.IME_ACTION_NEXT: case EditorInfo.IME_ACTION_DONE: users.clear(); mListView.setAdapter(new UserAdapter(SearchUser.this, users)); // 添加搜索 RequestParams params = new RequestParams(); params.put("myphone", telphone); params.put("fphone", v.getText().toString()); BaseAsyncHttp.postReq( getApplicationContext(), "/users/search", params, new JSONObjectHttpResponseHandler() { @Override public void jsonSuccess(JSONObject resp) { // TODO Auto-generated method stub if (resp.optString("nickname").equals("")) { Toast.makeText(getApplicationContext(), "所搜索用户不存在", Toast.LENGTH_SHORT) .show(); } else { User user = new User(); user.setId(resp.optString("id")); user.setUserName(resp.optString("nickname")); user.setHeadUrl(resp.optString("thumb")); user.setTelephone(resp.optString("phone")); user.setSex(resp.optString("gender")); user.setLocation(resp.optString("area")); user.setJob(resp.optString("job")); user.setHobby(resp.optString("hobby")); user.setSignature(resp.optString("signature")); isFriend = resp.optInt("isfriend"); Log.i("sdangmanm,vznlfawlkej", isFriend + ""); users.add(user); mListView.setAdapter(new UserAdapter(SearchUser.this, users)); } } @Override public void jsonFail(JSONObject resp) { // TODO Auto-generated method stub } }); break; } return false; } }); mListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub User user = users.get(position); if (user != null) { Intent intent = new Intent(SearchUser.this, UserDetail.class); intent.putExtra("nickname", user.getUserName()); intent.putExtra("phone", user.getTelephone()); intent.putExtra("mytelphone", telphone); intent.putExtra("thumb", user.getHeadUrl()); intent.putExtra("gender", user.getSex()); intent.putExtra("area", user.getLocation()); intent.putExtra("signature", user.getSignature()); intent.putExtra("isFriend", isFriend); intent.putExtra("fromwhere", "search"); startActivity(intent); } } }); }