我正在使用以下代码:-
@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 无法点击任何人建议我。我正在使用 github pulltorefresh 代码。我无法找出问题所在,因为在其他地方它正在工作..