这可能非常简单,但我是Android新手。代码调试很好,但是当我尝试生成签名的APK时,我会遇到构建错误。使用Android Studio 3.0.1
错误:对LayoutParams的意外隐式强制转换:布局标记为FrameLayout [WrongViewCast]
这个位是下面代码中错误突出显示3次的地方(这不是完整的功能,只是突出显示错误的位):
findViewById(R.id.frame_layout_2).getLayoutParams())。weight> 0)
public void onBackPressed() {
switch (mCurrentFragmentIndex) {
case ALERTS_FRAGMENT_ID:
if (getScreenWidth() >= dualFragmentWidth &&
((LinearLayout.LayoutParams) findViewById(R.id.frame_layout_2).getLayoutParams()).weight > 0) {
shrinkSecondFragment();
//unselect the list item
if (getSupportFragmentManager().findFragmentById(R.id.frame_layout) != null) {
((CollatedAlertsFragment) getSupportFragmentManager().findFragmentById(R.id.frame_layout)).unselectItem();
}
return;
}
break;
case MYSCHOOP_FRAGMENT_ID:
if (getScreenWidth() >= dualFragmentWidth &&
((LinearLayout.LayoutParams) findViewById(R.id.frame_layout_2).getLayoutParams()).weight > 0) {
shrinkSecondFragment();
return;
}
break;
case SETTINGS_FRAGMENT_ID:
if (getScreenWidth() >= dualFragmentWidth &&
((LinearLayout.LayoutParams) findViewById(R.id.frame_layout_2).getLayoutParams()).weight > 0) {
shrinkSecondFragment();
return;
}
break;
这是 frame_layout_2
的XML <LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:baselineAligned="true">
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<FrameLayout
android:id="@+id/frame_layout_2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0" />
</LinearLayout>
感谢任何帮助或建议。感谢
答案 0 :(得分:0)
抱歉,我读错了。
这是一个隐式的强制转换错误,而不是一个明确的强制转换错误。
问题是这个
getSupportFragmentManager().findFragmentById(R.id.frame_layout)
这里android试图获取一个id为“frame_layout”
的片段但是这个id属于FrameLayout而不是片段。
您应该使用以下语句声明标记:
<fragment>
答案 1 :(得分:0)
您需要在
周围添加其他括号 read_csv
例如,
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: <<Removed>>' -F file=@"/home/xxx/Desktop/customers.json" 'API_SERVER_URL' -k