我试图让弹出窗口显示发票的详细信息。我在互联网上查看示例,它们看起来都是这样的,所以当我尝试给视图充气时,我不明白为什么会出错。我注意到的唯一事情是它在项目布局文件夹中的invoice_look之后有单词(port)。 我收到了这个错误:
View popupView = layoutInflater.inflate(R.layout.invoice_look,null);
this = {com.android.internal.os.RuntimeInit$UncaughtHandler@21167}
shadow$_klass_ = {java.lang.Class@20712} "class com.android.internal.os.RuntimeInit$UncaughtHandler"
accessFlags = 524288
classLoader = null
classSize = 416
clinitThreadId = 14084
componentType = null
dexCache = {java.lang.DexCache@21169}
dexCacheStrings = {java.lang.String[105519]@21170}
dexClassDefIndex = 3975
dexTypeIndex = 4549
directMethods = {java.lang.reflect.ArtMethod[2]@21171}
iFields = null
ifTable = {java.lang.Object[2]@21172}
name = {java.lang.String@21173} "com.android.internal.os.RuntimeInit$UncaughtHandler"
numReferenceInstanceFields = 0
numReferenceStaticFields = 0
objectSize = 8
primitiveType = 0
referenceInstanceOffsets = -2147483648
referenceStaticOffsets = 0
sFields = null
status = 10
superClass = {java.lang.Class@20126} "class java.lang.Object"
verifyErrorClass = null
virtualMethods = {java.lang.reflect.ArtMethod[1]@21174}
vtable = null
shadow$_klass_ = {java.lang.Class@18444} "class java.lang.Class"
shadow$_monitor_ = -1493239949
shadow$_monitor_ = -1272289465
以下是我活动中的代码。
lookBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
LayoutInflater layoutInflater = (LayoutInflater) Pickup.this.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.invoice_look,null);
final PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Button dismissBtn = (Button) popupView.findViewById(R.id.lookDismiss);
dismissBtn.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
popupWindow.dismiss();
}
});
popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
}
});
这是invoice_look窗口的XML。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/invLookLayout">
<ListView
android:id="@+id/listView"
android:layout_width="500dp"
android:layout_height="520dp" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
style="@style/BlackSText"
android:id="@+id/textView25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/discount" />
<TextView
style="@style/BlackSText"
android:id="@+id/textView26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start" />
<TextView
style="@style/BlackSText"
android:id="@+id/lookDiscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end" />
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
style="@style/BlackSText"
android:id="@+id/textView28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/env" />
<TextView
style="@style/BlackSText"
android:id="@+id/textView29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start" />
<TextView
style="@style/BlackSText"
android:id="@+id/lookEnviro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end" />
</TableRow>
<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
style="@style/BlackSText"
android:id="@+id/textView31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/salestax" />
<TextView
style="@style/BlackSText"
android:id="@+id/textView32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start" />
<TextView
style="@style/BlackSText"
android:id="@+id/lookSalesTax"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end" />
</TableRow>
<TableRow
android:id="@+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
style="@style/BlackText"
android:id="@+id/textView34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/total" />
<TextView
style="@style/BlackText"
android:id="@+id/lookPcs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:text="@string/pcs" />
<TextView
style="@style/BlackText"
android:id="@+id/lookTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end" />
</TableRow>
</TableLayout>
<TextView
style="@style/BlackText"
android:id="@+id/textView24"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="5"
android:columnOrderPreserved="true"
android:rowCount="1"
android:rowOrderPreserved="false"
android:useDefaultMargins="false"
android:orientation="horizontal"
android:id="@+id/gridLayout"
android:focusableInTouchMode="false" >
<Button
style="@style/BlackSText"
android:id="@+id/lookDismiss"
android:layout_width="96dp"
android:layout_height="70dp"
android:layout_column="0"
android:layout_row="0"
android:background="@drawable/lightrebbtn"
android:text="@string/cancel"
android:layout_gravity="fill_horizontal" />
<Button
style="@style/BlackSText"
android:id="@+id/button58"
android:layout_width="96dp"
android:layout_height="70dp"
android:layout_column="1"
android:layout_row="0"
android:background="@drawable/yellowbtn"
android:text="@string/del"
android:layout_gravity="fill_horizontal" />
<Button
style="@style/BlackSText"
android:id="@+id/button61"
android:layout_width="96dp"
android:layout_height="70dp"
android:layout_column="2"
android:layout_row="0"
android:background="@drawable/yellowbtn"
android:text="@string/price"
android:layout_gravity="fill_horizontal" />
<Button
style="@style/BlackSText"
android:id="@+id/button62"
android:layout_width="96dp"
android:layout_height="70dp"
android:layout_column="3"
android:layout_row="0"
android:background="@drawable/yellowbtn"
android:text="@string/myo"
android:layout_gravity="fill_horizontal" />
<Button
style="@style/BlackSText"
android:id="@+id/button63"
android:layout_width="96dp"
android:layout_height="70dp"
android:layout_column="4"
android:layout_row="0"
android:background="@drawable/yellowbtn"
android:text="@string/coupon"
android:layout_gravity="fill_horizontal" />
</GridLayout>
</LinearLayout>