我有一个像这样的
我只想创建一个OnItemClick事件,但每次点击项目时,即使有
我还看到了一个奇怪的日志,有时它会说“true”,有时它会说“false”:
而且Logcat仅在真实设备上显示。使用AVD,则没有显示任何内容。
感谢您宝贵的时间。
cart_layout
:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:id="@+id/cart_listview"
android:layout_gravity="center_horizontal"
android:background="@color/whiteBg"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="bottom"
android:padding="5dp"
android:gravity="bottom"
android:background="@color/whiteBg">
<!-- this layout contains a button and a textview which I don't think is the problem -->
</LinearLayout>
</LinearLayout>
在Cart.java
中的Java代码:
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cart_layout);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
dbhandler = new DatabaseHandler(this);
product_all = dbhandler.getProduct();
total = (TextView)findViewById(R.id.cart_total_textview);
listview = (ListView)findViewById(R.id.cart_listview);
cart_adapter = new Custom_Cart_Adapter(this,product_all);
listview.setAdapter(cart_adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.v("ITEM CLICK","CLICKED ITEM POSITION: "+position);
Intent intent = new Intent(Cart.this, Item_edit_details.class);
intent.putExtra("the_product", product_all.get(position));
startActivity(intent);
}
});
}
我只想创建一个OnItemClick事件,但每次点击项目时,即使有
listview.setOnItemClickListener
,Logcat也会显示以下内容:
然后什么也不会发生。ViewRootImpl:ViewPostImeInputStage处理指针0
ViewRootImpl:ViewPostImeInputStage处理指针1
我还看到了一个奇怪的日志,有时它会说“true”,有时它会说“false”:
我不知道它是否与问题有关,而且我也不知道问题是什么时候出现的,可能是在我弄乱某些东西之后。ActivityThread:updateVisibility:ActivityRecord {3308191 token = android.os.BinderProxy @ c7ed098 {com.iwant.namhhgames.newiwant / com.iwant.namhhgames.newiwant.Listing_items}} show:false
而且Logcat仅在真实设备上显示。使用AVD,则没有显示任何内容。
感谢您宝贵的时间。