私は次のコードを使用しています:-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newsfeed);
setAllControlls();
myPrefs = this.getSharedPreferences(
AppConstants.MYPREF, MODE_WORLD_READABLE);
userid = myPrefs.getString(AppConstants.USER_ID, "");
if(checkInternet(NewFeeds.this))
{
new callNewsfeeddata().execute(userid);
}
else
{
Toast.makeText(NewFeeds.this,"Please Check Your Internet Connection",Toast.LENGTH_LONG).show();
}
objlistview.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
if(checkInternet(NewFeeds.this))
{
new callNewsfeeddata().execute(userid);
}
else
{
Toast.makeText(NewFeeds.this,"Please Check Your Internet Connection",Toast.LENGTH_LONG).show();
}
}
});
objHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case AppConstants.UPDATE_ADDRESS:
if (!((String) msg.obj).equals("0")) {
System.out.println("inside---" + objlocationvalue);
objlocationvalue = (String) msg.obj;
} else {
objlocationvalue = "1";
}
break;
}
}
};
objLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
}
private void setAllControlls() {
objlistview = (PullToRefreshListView) findViewById(R.id.newsfeedlistview);
objlistview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos,
long arg3) {
int pos1=pos-1;
NewsFeedModle objnewsfeedmodle = objlist.get(pos);
String type = objnewsfeedmodle.getType();
if(type.equalsIgnoreCase("job"))
{
String postid = objnewsfeedmodle.getJobId();
Intent objintent = new Intent(NewFeeds.this,ShowNewPostJobDetails.class);
Bundle objbundle = new Bundle();
objbundle.putString("postid", postid);
objbundle.putString("from","newsfeed");
objintent.putExtras(objbundle);
startActivity(objintent);
}
if(type.equalsIgnoreCase("deals"))
{
String postid = objnewsfeedmodle.getDealid();
Intent objintent = new Intent(NewFeeds.this,ShowNewFindDeal.class);
Bundle objbundle = new Bundle();
objbundle.putString("postid", postid);
objbundle.putString("from","newsfeed");
objintent.putExtras(objbundle);
startActivity(objintent);
}
if(type.equalsIgnoreCase("stuff"))
{
String postid = objnewsfeedmodle.getStuffId();
Intent objintent = new Intent(NewFeeds.this,ShowNewFindStuff.class);
Bundle objbundle = new Bundle();
objbundle.putString("postid", postid);
objbundle.putString("from","newsfeed");
objintent.putExtras(objbundle);
startActivity(objintent);
}
}
});
}
private class callNewsfeeddata extends
AsyncTask<String, Void, List<NewsFeedModle>> {
ProgressDialog objprogress = new ProgressDialog(NewFeeds.this);
AppRequestHandler objApprequest = new AppRequestHandler();
List<NewsFeedModle> objresponce = new ArrayList<NewsFeedModle>();
@Override
protected void onPreExecute() {
objprogress.setMessage("Please Wait While Loading...");
objprogress.show();
}
@Override
protected List<NewsFeedModle> doInBackground(String... params) {
objresponce = objApprequest.newsFeedRequest(params[0]);
return objresponce;
}
@Override
protected void onPostExecute(List<NewsFeedModle> result) {
if (objprogress.isShowing()) {
objprogress.dismiss();
}
if(objlist!=null && objlist.size()!=0)
{
objlist.clear();
}
String msgcount="";
if (result != null)
{
objlist=result;
if(objlist.size()==0)
{
Log.i("check",""+objlist.size());
Log.i("check22222",""+result.size());
}
if(objlist!=null && objlist.size()!=0)
{
msgcount = objlist.get(0).getMessagescount();
}
TabActivity tab=(TabActivity) getParent();
TextView tv=(TextView) tab.findViewById(R.id.notificationmsg);
tv.setText(msgcount);
Editor objedit = myPrefs.edit();
objedit.putString(AppConstants.MESSAGECOUNT, msgcount);
objedit.commit();
objnewsFeedAdapter = new NewsFeedAdapter(NewFeeds.this,objlist,(float)objlattvalue,(float)objlongvalue,objlocationvalue);
objlistview.setAdapter(objnewsFeedAdapter);
objnewsFeedAdapter.notifyDataSetChanged();
objlistview.onRefreshComplete();
}
}
}
setAllContrill メソッド内で OnItemClickLIstener を定義しましたが、機能していません。listView はクリックできません。だれかが私に提案してください。