gpt4 book ai didi

android - 为什么 OnItemClickLIstener 不适用于 PullToRefreshLIstView?

转载 作者:搜寻专家 更新时间:2023-11-01 07:35:02 25 4
gpt4 key购买 nike

我正在使用以下代码:-

@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 代码。我无法找出问题所在,因为在其他地方它正在工作..

最佳答案

尝试:`

objlistview.getRefreshableView().setOnItemClickListener(new OnItemClickListener...)

关于android - 为什么 OnItemClickLIstener 不适用于 PullToRefreshLIstView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12625155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com