gpt4 book ai didi

安卓程序

转载 作者:行者123 更新时间:2023-11-29 22:09:47 25 4
gpt4 key购买 nike

我创建了一个 Android 应用程序,但它运行不正常。我不知道为什么它总是在控制台的这一行停止。

[2012-03-29 13:23:00 - AndroidBitmap] Starting activity com.example.Android.AndroidBitmapActivity on device emulator-5554

我的程序如下,是位图旋转的代码 包 com.example.Android;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.Spinner;

public class AndroidBitmapActivity extends Activity {

private final String imageInSD = "/sdcard/er.PNG";

ImageView myImageView;
Spinner spinnerScale;
SeekBar seekbarRotate;

private static final String[] strScale
= {"0.2x", "0.5x", "1.0x", "2.0x", "5.0x"};
private static final Float[] floatScale
= {0.2F, 0.5F, 1F, 2F, 5F};
private final int defaultSpinnerScaleSelection = 2;

private ArrayAdapter<String> adapterScale;

private float curScale = 1F;
private float curRotate = 0F;

Bitmap bitmap;
int bmpWidth, bmpHeight;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

myImageView = (ImageView)findViewById(R.id.imageview);

spinnerScale = (Spinner)findViewById(R.id.scale);
seekbarRotate = (SeekBar)findViewById(R.id.rotate);

adapterScale = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, strScale);
adapterScale.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerScale.setAdapter(adapterScale);
spinnerScale.setSelection(defaultSpinnerScaleSelection);
curScale = floatScale[defaultSpinnerScaleSelection];

bitmap = BitmapFactory.decodeFile(imageInSD);
bmpWidth = bitmap.getWidth();
bmpHeight = bitmap.getHeight();

drawMatrix();

spinnerScale.setOnItemSelectedListener(spinnerScaleOnItemSelectedListener);
seekbarRotate.setOnSeekBarChangeListener(seekbarRotateSeekBarChangeListener);

}

private void drawMatrix(){

Matrix matrix = new Matrix();
matrix.postScale(curScale, curScale);
matrix.postRotate(curRotate);

Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true);
myImageView.setImageBitmap(resizedBitmap);

}

private SeekBar.OnSeekBarChangeListener seekbarRotateSeekBarChangeListener
= new SeekBar.OnSeekBarChangeListener(){

@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
curRotate = (float)progress;
drawMatrix();
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub

}};

private Spinner.OnItemSelectedListener spinnerScaleOnItemSelectedListener
= new Spinner.OnItemSelectedListener(){

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
curScale = floatScale[arg2];
drawMatrix();
}

@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
spinnerScale.setSelection(defaultSpinnerScaleSelection);
curScale = floatScale[defaultSpinnerScaleSelection];
}};
}

我的 list 文件如下

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Android"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidBitmapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

我的控制台显示以下内容

[2012-03-29 13:23:00 - AndroidBitmap] Android Launch!
[2012-03-29 13:23:00 - AndroidBitmap] adb is running normally.
[2012-03-29 13:23:00 - AndroidBitmap] Performing com.example.Android.AndroidBitmapActivity activity launch
[2012-03-29 13:23:00 - AndroidBitmap] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'A2.2'
[2012-03-29 13:23:00 - AndroidBitmap] WARNING: Unknown device API version!
[2012-03-29 13:23:00 - AndroidBitmap] Uploading AndroidBitmap.apk onto device 'emulator-5554'
[2012-03-29 13:23:00 - AndroidBitmap] Installing AndroidBitmap.apk...
[2012-03-29 13:23:00 - AndroidBitmap] Success!
[2012-03-29 13:23:00 - AndroidBitmap] Starting activity com.example.Android.AndroidBitmapActivity on device emulator-5554

最佳答案

我猜我会说你没有在你的 AndroidManifest.xml 文件中声明 AndroidBitmapActivity,但我认为如果你发布更多的堆栈跟踪(可能还有 list 文件)会有所帮助。

关于安卓程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9921037/

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