在我的应用程序中,我希望在单击警告对话框时显示透明面板ok按钮。在mapview.i的ontap方法中显示了对话框,为创意透明面板创建了单独的类,现在按下Ok按钮点击该类。
在膨胀时我正在获得由于未找到类异常引起的异常布局缓冲器异常。
这是我的代码
@Override
protected boolean onTap(int i) {
final Animation animShow;
final Animation animHide;
AlertDialog.Builder builder = null;
OverlayItem item=getItem(i);
builder=new AlertDialog.Builder(mcontext);
builder.setTitle(item.getTitle());
animShow = AnimationUtils.loadAnimation(FindFishActivity.this, R.anim.popup_show);
animHide = AnimationUtils.loadAnimation( FindFishActivity.this, R.anim.popup_hide);
builder.setPositiveButton("Show Info",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
onShowInfo();
}
public void onShowInfo() {
LayoutInflater inflater=LayoutInflater.from(FindFishActivity.this);
View view=inflater.inflate(R.layout.tutorial5,(ViewGroup)findViewById(R.id.linearlayoutID));
transparentPanel=(TransparentPanel)view.findViewById(R.id.popup_window);
transparentPanel.setVisibility(View.VISIBLE);
transparentPanel.startAnimation(animShow);
}
});
builder.show();
return true;
}
我的transperantpanel类,它是从线性布局
扩展而来的公共类TransparentPanel扩展了LinearLayout { private Paint innerPaint,borderPaint;
public TransparentPanel(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public TransparentPanel(Context context) {
super(context);
init();
}
private void init() {
innerPaint = new Paint();
innerPaint.setARGB(225, 75, 75, 75); //gray
innerPaint.setAntiAlias(true);
borderPaint = new Paint();
borderPaint.setARGB(255, 255, 255, 255);
borderPaint.setAntiAlias(true);
borderPaint.setStyle(Style.STROKE);
borderPaint.setStrokeWidth(2);
}
public void setInnerPaint(Paint innerPaint) {
this.innerPaint = innerPaint;
}
public void setBorderPaint(Paint borderPaint) {
this.borderPaint = borderPaint;
}
@Override
protected void dispatchDraw(Canvas canvas) {
RectF drawRect = new RectF();
drawRect.set(0,0, getMeasuredWidth(), getMeasuredHeight());
canvas.drawRoundRect(drawRect, 5, 5, innerPaint);
canvas.drawRoundRect(drawRect, 5, 5, borderPaint);
super.dispatchDraw(canvas);
}
和我的xml文件
<view class="com.android.fishdemo.FindFishActivity.MyOverlays$TransparentPanel"
android:id="@+id/popup_window"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left"
android:padding="1px"
android:background="@drawable/white">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="right"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/button_bar_gradient">
<Button android:id="@+id/hide_popup_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="5px"
android:layout_marginRight="10px"
android:paddingLeft="5px"
android:paddingRight="5px"
style="?android:attr/buttonStyleSmall"
android:textStyle="bold"
android:textColor="@drawable/white"
android:textSize="12px"
android:text="Close"
android:background="@drawable/button_black_rounded_out"/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_marginTop="5px"
android:layout_below="@+id/hide_popup_button"
android:background="@drawable/white"/>
</RelativeLayout>
<TextView android:id="@+id/location_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="16px"
android:textColor="@drawable/white"
android:layout_marginTop="5px"
android:layout_marginLeft="5px"/>
<TextView android:id="@+id/location_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@drawable/white"
android:layout_margin="5px"/>
</view>
请帮帮我... 感谢