gpt4 book ai didi

java - Android 显示图像 - Surface 无效

转载 作者:太空宇宙 更新时间:2023-11-03 12:51:02 26 4
gpt4 key购买 nike

06-30 11:59:40.153  27202-27202/com.downloader.newlevel.krim.newleveldownloader E/ViewSystem﹕ ViewRootImpl #2 Surface is not valid.
06-30 11:59:41.114 27202-27216/com.downloader.newlevel.krim.newleveldownloader E/Error﹕ https://photos-4.dropbox.com/t/2/AAAxrzwz2B32dmtjRTNlT1vhQfVd5JuglMkbVV_m8BRkLg/12/145533347/png/32x32/1/_/1/2/Hourglass%20Addon%20by%20Redstone.png/CKPTskUgASACIAMgBCAFIAYgBygBKAI/Jpa4t4f3nMDieOULhjrmus_8mVpqVO37XxrQYkzMoSo?size=800x600&size_mode=2
06-30 12:00:57.429 27202-27202/com.downloader.newlevel.krim.newleveldownloader E/ViewSystem﹕ ViewRootImpl #2 Surface is not valid.
06-30 12:00:58.219 27202-27755/com.downloader.newlevel.krim.newleveldownloader E/Error﹕ https://photos-4.dropbox.com/t/2/AAAxrzwz2B32dmtjRTNlT1vhQfVd5JuglMkbVV_m8BRkLg/12/145533347/png/32x32/1/_/1/2/Hourglass%20Addon%20by%20Redstone.png/CKPTskUgASACIAMgBCAFIAYgBygBKAI/Jpa4t4f3nMDieOULhjrmus_8mVpqVO37XxrQYkzMoSo?size=800x600&size_mode=2

这是在我的 logcat 中找到的,我目前正致力于从 url 加载图像。

Activity

        package com.downloader.newlevel.krim.newleveldownloader;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;

import java.io.InputStream;


public class activity00 extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity00);
String url000 = "https://photos-4.dropbox.com/t/2/AAAxrzwz2B32dmtjRTNlT1vhQfVd5JuglMkbVV_m8BRkLg/12/145533347/png/32x32/1/_/1/2/Hourglass%20Addon%20by%20Redstone.png/CKPTskUgASACIAMgBCAFIAYgBygBKAI/Jpa4t4f3nMDieOULhjrmus_8mVpqVO37XxrQYkzMoSo?size=800x600&size_mode=2";
new DownloadImageTask((ImageView) findViewById(R.id.image_main00)).execute(url000);
Intent splash = new Intent(this, splash_activity.class);
startActivity(splash);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.settings, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_search) {
return true;
}

return super.onOptionsItemSelected(item);
}
}

AsyncTask 下载图片

class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;

public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}

protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}

protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}

布局

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/scrollView"
xmlns:tools="http://schemas.android.com/tools"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
tools:context=".activity00"
xmlns:android="http://schemas.android.com/apk/res/android">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">

<TableLayout
android:id="@+id/tableLayout_main00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow>
<Button
android:text="Script"
android:textAllCaps="false"
android:background="#ffffff"/>
<Button
android:text="Add-on"
android:textAllCaps="false"
android:background="#fffffa6a"/>
</TableRow> <TableRow>
<Button
android:text="Map"
android:textAllCaps="false"
android:background="#ff6ec0ff"/>
<Button
android:text="Skin"
android:textAllCaps="false"
android:background="#ffff6d66"/>
</TableRow> <TableRow>
<Button
android:text="Texture Pack"
android:textAllCaps="false"/>
<Button
android:text="Coming Soon"
android:textAllCaps="false"/>
</TableRow>
</TableLayout>

<TextView
android:id="@+id/text_main00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New"
android:textSize="20sp"
android:layout_below="@+id/tableLayout_main00"
android:clickable="true"
android:gravity="right"
android:layout_marginTop="20dp"/>

<android.support.v7.widget.CardView
android:id="@+id/cardview_main00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
cardview:cardCornerRadius="4dp"
android:layout_below="@+id/text_main00"
android:clickable="true"
android:layout_marginTop="5dp">

<ImageView
android:id="@+id/image_main00"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scaleType="fitStart"/>

<TextView
android:id="@+id/text_main_cardview00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hourglass Addon by Redstone"
android:layout_gravity="bottom"/>

</android.support.v7.widget.CardView>

<TextView
android:id="@+id/text_main01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Popular"
android:textSize="20sp"
android:layout_below="@+id/cardview_main00"
android:clickable="true"
android:gravity="right"
android:layout_marginTop="10dp"/>

<android.support.v7.widget.CardView
android:layout_below="@+id/text_main01"
android:id="@+id/cardview_main01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
cardview:cardCornerRadius="4dp"
android:clickable="true"
android:layout_marginTop="5dp">

<ImageView
android:id="@+id/image_main01"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scaleType="fitStart"/>

<TextView
android:id="@+id/text_main_cardview01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Armor Display by Chan"
android:layout_gravity="bottom"/>

</android.support.v7.widget.CardView>

<TextView
android:id="@+id/text_main02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Coming Soon"
android:textSize="20sp"
android:layout_below="@+id/cardview_main01"
android:clickable="true"
android:gravity="right"
android:layout_marginTop="10dp"/>

<android.support.v7.widget.CardView
android:layout_below="@+id/text_main02"
android:id="@+id/cardview_main02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
cardview:cardCornerRadius="4dp"
android:clickable="true"
android:layout_marginTop="5dp">

<ImageView
android:id="@+id/image_main02"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scaleType="fitStart"/>

<TextView
android:id="@+id/text_main_cardview02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PortalPX by TM"
android:layout_above="@+id/text_main_cardview22"/>

<TextView
android:id="@+id/text_main_cardview22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Limited Edition: Cabon Version"
android:layout_gravity="bottom"/>


</android.support.v7.widget.CardView>


</RelativeLayout>

</ScrollView>

不知道为什么会出现这个logcat。谁能解释一下并解决它?

最佳答案

“ViewRootImpl #2 Surface 无效。”在 logcat 中意味着布局出了问题。我通过再次编写整个布局来修复我的......以确保一切正常:)启动画面与此错误无关

关于java - Android 显示图像 - Surface 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31146611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com