【发布时间】:2017-01-08 18:10:16
【问题描述】:
我的活动是一个视频播放器活动,它工作正常,在某些视频上,如果视频不受支持或质量很高,它必须抛出一条消息 (handleHardwareAccelerationError)。 它显示为带有消息的 Toast。 现在我想更改此 Toast 消息以显示图片或小图标,这可能吗?这是我的handleHardwareAccelerationError代码,提前致谢。
private void handleHardwareAccelerationError() {
mHardwareAccelerationError = true;
if (mSwitchingView)
return;
Toast.makeText(this, R.string.hardware_acceleration_error, Toast.LENGTH_LONG).show();
}
我尝试过的是这个,但没有显示任何内容。
private void handleHardwareAccelerationError() {
mHardwareAccelerationError = true;
if (mSwitchingView)
return;
final View popupView = getLayoutInflater().inflate(R.layout.myinforbar, null);
mError = (ImageView) popupView.findViewById(R.id.errornew);
mError.setVisibility(View.VISIBLE);
}
这里是 myinforbar.xml
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="21dp" android:layout_marginLeft="0.0dip" android:layout_marginTop="5.0dip"
android:background="@drawable/button5_background">
<ImageView
android:id="@+id/errornew"
android:src="@drawable/everyone_icon_nearby_cur"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:visibility="invisible"/>
</LinearLayout>
编辑:
原始活动很长,可以在这里找到而不是粘贴整个活动你可以在这里看到它VideoPlayerActivity (私有无效句柄HardwareAccelerationError)
新更新...
这没有应用消息(onHardwareError),我想在这个底部小框内看到在播放视频时弹出的图标(信息栏)而不是 Toast 消息。
【问题讨论】:
-
试试tastytoast,它看起来很棒很酷的动画。
标签: java android drawable show toast