- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
private void showPopup(final Activity context, Point p) {
int popupWidth = 800;
int popupHeight = 1100;
// Inflate the popup_layout.xml
LinearLayout viewGroup = (LinearLayout) context
.findViewById(R.id.popup);
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.notifcationpopup_layout,
viewGroup);
popup = new PopupWindow(context);
popup.setContentView(layout);
popup.setWidth(popupWidth);
popup.setHeight(popupHeight);
popup.setFocusable(true);
// Some offset to align the popup a bit to the right, and a bit down,
// relative to button's position.
int OFFSET_X = 100;
int OFFSET_Y = 40;
// Clear the default translucent background
popup.setBackgroundDrawable(new BitmapDrawable());
// Displaying the popup at the specified location, + offsets.
popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y
+ OFFSET_Y);
rowItems = new ArrayList<RowItem>();
// for (int i = 0; i < titles.length; i++) {
// RowItem item = new RowItem(titles[i], descriptions[i]);
// rowItems.add(item);
// }
dbManager1 = new DataBaseManager(context);
notifies = dbManager1.getNotificationList();
System.out.println("today " + notifies.size());
for (int i = 0; i < notifies.size(); i++) {
System.out
.println("Valueeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:"
+ notifies.get(i).getNotificationDescrpiton()
+ "\n"
+ notifies.get(i).getNotificationServerId()
+ "\n" + notifies.get(i).getNotificationDatetime());
}
listView = (ListView) layout.findViewById(R.id.listView1);
Notifcationadapter adapter = new Notifcationadapter(this, notifies);
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
String notifcationtype = notifies.get(position).getNotificationType();
String nOtifcationMessge = notifies.get(position)
.getNotificationDescrpiton();
String notifcationdatetime = notifies.get(position)
.getNotificationDatetime();
String NotifcationSenderid = notifies.get(position)
.getNotificationSenderID();
String NotifcationRecciverid = notifies.get(position)
.getNotificationRecieverID();
final int positionRow = listView.getPositionForView((View) view
.getParent());
String Latreccvier = "";
String Lonreccvier = "";
Cursor cursor = dbManager1.fetchContactInfo(NotifcationRecciverid);
if (cursor != null && cursor.moveToFirst()) {
Latreccvier = cursor.getString(cursor
.getColumnIndex(DataProviderConstants.CONTACT_LAT_COLUMN));
Lonreccvier = cursor.getString(cursor
.getColumnIndex(DataProviderConstants.CONTACT_LON_COLUMN));
cursor.close();
}
Log.e("Reccvierid", NotifcationRecciverid);
Log.e("Reccvierid", Latreccvier);
Log.e("Reccvierid", Lonreccvier);
// Intent i = null;
if (notifcationtype.equals("1")) {
// i = new Intent(context, PostActivity.class);
Intent i = new Intent(this, RoutePathActivity.class);
i.putExtra("lat", Latreccvier);
i.putExtra("lon", Lonreccvier);
startActivity(i);
Toast.makeText(this, "Request", 1000).show();
} else if (notifcationtype.equals("2")) {
displayView(0);
// ((FragHome) fragment).showMap();
popup.dismiss();
Toast.makeText(this, "Post", 1000).show();
}
}
这是我的弹出窗口的 HOmeActivity 代码。
public class Notifcationadapter extends BaseAdapter {
private static ArrayList<Notify> values;
Context context;
String senderid;
String imagepath;
// List<RowItem> rowItems;
ViewHolder holder = null;
LinearLayout linear2;
DataBaseManager dbManager = new DataBaseManager(context);
ArrayList<Notify> notifies;
public Notifcationadapter(Context context, ArrayList<Notify> notifies) {
super();
this.context = context;
this.notifies = notifies;
}
/* private view holder class */
private class ViewHolder {
TextView txtTitle;
TextView txtDesc;
ImageView yesimage;
ImageView noimage;
TextView revresetime;
TextView rejected;
ImageView notificationuserimage;
LinearLayout linear2;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.notifcationlistitem, null);
holder = new ViewHolder();
holder.linear2 = (LinearLayout) convertView
.findViewById(R.id.linear2);
holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
holder.txtTitle = (TextView) convertView.findViewById(R.id.title);
holder.yesimage = (ImageView) convertView
.findViewById(R.id.imageView1);
holder.noimage = (ImageView) convertView
.findViewById(R.id.imageView2);
holder.revresetime = (TextView) convertView
.findViewById(R.id.revresetime);
holder.rejected = (TextView) convertView
.findViewById(R.id.rejectedrequest);
holder.notificationuserimage = (ImageView) convertView
.findViewById(R.id.notificationuserimage);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// holder.txtTitle.setText("Title");
String statustype = notifies.get(position).getNotificationType();
if (statustype.equals("1")) {
holder.txtDesc.setText(notifies.get(position)
.getNotificationDescrpiton());
holder.revresetime.setText(Functions
.setLastSeenNotifcationTime(notifies.get(position)
.getNotificationDatetime()));
holder.txtTitle.setText("Request For travelling");
senderid = notifies.get(position).getNotificationSenderID();
imagepath = "http://api.lociiapp.com/TransientStorage/"
+ senderid + ".jpg";
AQuery aq = new AQuery(context);
aq.id(holder.notificationuserimage).image(imagepath);
holder.yesimage.setVisibility(View.VISIBLE);
holder.noimage.setVisibility(View.VISIBLE);
holder.yesimage.setTag(convertView);
holder.yesimage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
View parentView = (View) arg0.getTag();
View view = parentView.findViewById(R.id.imageView1);
view.setVisibility(View.GONE);
view = parentView.findViewById(R.id.imageView2);
view.setVisibility(View.GONE);
view = parentView.findViewById(R.id.linear2);
view.setVisibility(View.INVISIBLE);
view = parentView.findViewById(R.id.runnimage);
view.setVisibility(View.INVISIBLE);
Toast.makeText(context, "Yes", 10000).show();
}
});
holder.noimage.setTag(convertView);
holder.noimage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
View parentView = (View) v.getTag();
View view = parentView.findViewById(R.id.imageView1);
view.setVisibility(View.GONE);
view = parentView.findViewById(R.id.imageView2);
view.setVisibility(View.GONE);
view = parentView.findViewById(R.id.rejectedrequest);
view.setVisibility(View.VISIBLE);
Toast.makeText(context, "NO", 10000).show();
// holder.linear2.setVisibility(View.INVISIBLE);
holder.yesimage.setVisibility(View.GONE);
holder.noimage.setVisibility(View.GONE);
holder.rejected.setVisibility(View.VISIBLE);
}
});
}
else {
holder.txtDesc.setText(notifies.get(position)
.getNotificationDescrpiton());
holder.txtTitle.setText("Post");
holder.revresetime.setText(Functions
.setLastSeenNotifcationTime(notifies.get(position)
.getNotificationDatetime()));
senderid = notifies.get(position).getNotificationSenderID();
imagepath = "http://api.lociiapp.com/TransientStorage/"
+ senderid + ".jpg";
AQuery aq = new AQuery(context);
holder.yesimage.setVisibility(View.GONE);
holder.noimage.setVisibility(View.GONE);
}
if (position % 2 == 0) {
convertView.setBackgroundColor(Color.parseColor("#ffffff"));
}
else {
convertView.setBackgroundColor(Color.parseColor("#f5f6f1"));
}
return convertView;
}
@Override
public int getCount() {
return notifies.size();
}
@Override
public Object getItem(int position) {
return notifies.get(position).getNotificationType();
}
@Override
public long getItemId(int position) {
return position;
}
}
这是我的 ListView 适配器类,当打印 ListView 时,每个 ListView 项中有一个按钮 YES 或 No。我想当我们点击是按钮时,只有 itemclik 应该工作我的意思是点击一个项目我应该进入另一个 Activity 如果我们点击否按钮那么它不应该工作项目点击意味着在列表项目上点击我不应该去另一个 Activity
下面是 ListView 屏幕:
最佳答案
请检查我是否已编辑您的代码。 yesimage 是你的勾选图像按钮。在您的 Notifcationadapter 类中更新以下代码。
holder.yesimage.setOnClickListener(new OnItemClickListener( position ));
private class OnItemClickListener implements OnClickListener{
private int mPosition;
OnItemClickListener(int position){
mPosition = position;
}
@Override
public void onClick(View arg0) {
context.onItemtickClick(mPosition);
}
}
在您的主页 Activity 中,为 onItemtickClick 添加以下代码。
public void onItemtickClick(int mPosition) {
// TODO Auto-generated method stub
Intent i = new Intent(HomeActivity.this,RoutePathActivity.class);
i.putExtra("lat", Latreccvier);
i.putExtra("lon", Lonreccvier);
startActivity(i);
}
关于android - 如何在android中为Listview的项目点击应用条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25718851/
menu Home Events Technical Schedule
我试图阻止触发默认 anchor 链接和 onclick 事件。 这是 HTML 代码: Google 我正在尝试使用以下 jQuery 代码阻止任何重定向的发生: $("#mylink").cli
我想在单击父 div 上的任意位置时切换我的 div,除非单击 anchor 元素。因此,例如,如果我单击示例中的第一个文本,我希望它切换,但在我的示例中的第二个文本上,我不希望它切换。 JSFidd
我在通过 jQuery 伪造 anchor 点击时遇到问题:为什么我的thickbox在我第一次点击输入按钮时出现,但第二次或第三次却没有出现? 这是我的代码: Link 当我直接点击链接时,它总是
我已经从 Mootools 切换到 jQuery,因为我认为它有更好的支持。我有这样的 HTML: Opcje Opcje Opcje Opcje Opcje Opcje Opcje JS
我是一名优秀的程序员,十分优秀!