我正在研究android 2.2 froyo应用程序.当我运行我的应用程序android 2.2,3.0那个时候完美运行.但是当我在Android 4.0上运行时,那时我给出了一个错误.很遗憾,应用程序已停止.请帮助我如何解决错误.
08-03 16:19:36.602: E/AndroidRuntime(581): FATAL EXCEPTION: main
08-03 16:19:36.602: E/AndroidRuntime(581): java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Parcel.readException(Parcel.java:1331)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Parcel.readException(Parcel.java:1281)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:634)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:3586)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1185)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.os.Looper.loop(Looper.java:137)
08-03 16:19:36.602: E/AndroidRuntime(581): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-03 16:19:36.602: E/AndroidRuntime(581): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 16:19:36.602: E/AndroidRuntime(581): …Run Code Online (Sandbox Code Playgroud) 在下面的代码中,它viewflipper并没有占据整个屏幕,它只是围绕着textview. 为什么会发生这种情况?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000ff" >
<ViewFlipper android:id="@+id/ViewFlipper01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#aa0000"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"></TextView>
</ViewFlipper>
</ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 是否可以以英寸计算android屏幕对角线尺寸.
我试过以下两种方法都不适合我的情况.
方法1:
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int absoluteHeightInPx = displayMetrics.heightPixels;
int absoluteWidthInPx = displayMetrics.widthPixels;
double diagonalPixels = Math.sqrt((absoluteHeightInPx * absoluteHeightInPx) + (absoluteWidthInPx * absoluteWidthInPx));
double diagonalInInches = diagonalPixels / displayMetrics.densityDpi;
Run Code Online (Sandbox Code Playgroud)
方法2:
float actualHeight = absoluteHeightInPx * deviceDensity;
float actualWidth = absoluteWidthInPx * deviceDensity;
float deviceDensity = displayMetrics.density;
float physicalPixelPerInchX = displayMetrics.xdpi;
float physicalPixelPerInchY = displayMetrics.ydpi;
float heightInInches = actualHeight / physicalPixelPerInchY;
float widhtInInches = actualWidth / physicalPixelPerInchX;
double diagonalInInches = Math.sqrt((heightInInches * heightInInches) + (widhtInInches * widhtInInches)); …Run Code Online (Sandbox Code Playgroud) 我有这个视频:http://www.youtube.com/v/oyB5QWcPSRo? version = 3&f = user_uploads&app = youtube_gdata,我需要它在我的应用程序中播放,我已经使用videoView测试失败了:有错误信息"无法播放视频"
MediaController mc = new MediaController(this);
mc.setAnchorView(vidYout);
mc.setMediaPlayer(vidYout);
Log.v("TAG","URL: "+YoutubeVO.url_video);
Uri video = Uri.parse("devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8");
//Uri video = Uri.parse(YoutubeVO.url_video);
vidYout.setMediaController(mc);
vidYout.setVideoURI(video);
vidYout.requestFocus();
vidYout.start();
Run Code Online (Sandbox Code Playgroud)
我试图更改URL,如果问题出在视频中,但不是.我也试过使用webView失败了
wvComunicado.getSettings().setLoadWithOverviewMode(true);
wvComunicado.getSettings().setUseWideViewPort(true);
wvComunicado.loadData(YoutubeVO.url_video, "text/html" , "UTF-8");
Run Code Online (Sandbox Code Playgroud)
关于如何玩它的任何想法?
谢谢!
我正在使用Parse SDK构建我的应用程序.
我可以使用Intents轻松地从库中获取Bitmap.我想将它们用作我的用户的个人资料图片.
但是,为了上传它,我必须将其转换为字节数组.此外,当我下载它时,它以字节数组的形式出现,我必须将其转换回Drawable.
为了将其转换为字节数组,我这样做:
public static byte[] bitmapToByteArray(Bitmap bmp)
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
return byteArray;
}
Run Code Online (Sandbox Code Playgroud)
我找不到如何将此byte []转换回Bitmap而不必先保存它.如何实现这一过程?
我在我的应用程序中使用片段.在包含许多视图的片段之一中存在scrollview.当用户点击edittext时,键盘会打开但是当用户点击键盘上的完成按钮时,键盘会被隐藏而留下黑屏.我尝试了很多自己,但没有运气.请指导我..
android android-keypad android-layout android-fragmentactivity
我制作了一个启动图像,以便在我的活动开始时显示..图像显示完美.但问题是我称之为
public class SplashImageActivity extends Activity {
protected boolean active = true;
protected int splashTime = 5000; // time to display the splash screen in ms
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// thread for displaying the SplashScreen
Thread splashTread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while(active && (waited < splashTime)) {
sleep(100);
if(active) {
waited += 100;
}
} …Run Code Online (Sandbox Code Playgroud) 所以我正在下载东西,它被放入内置下载应用程序,因为这是下载管理器的工作原理.我只想让用户点击一个打开内置下载应用程序的按钮.继承人我的尝试:
btnDownloads.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
PackageManager pakMan=MainActivity.context.getPackageManager();
Log.d("bebr", "Making pak");
if(pakMan!=null){
Intent downloadsIntent=new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.android.downloads","com.android.downlods.Downloads"));
ResolveInfo resolved=pakMan.resolveActivity(downloadsIntent, PackageManager.MATCH_DEFAULT_ONLY);
Log.d("bebr","Resolving");
if(resolved!=null){
Log.d("bebr", "Starting");
startActivity(downloadsIntent);
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
好的,终于设法得到了解决方案:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
Run Code Online (Sandbox Code Playgroud) android launcher android-intent android-4.0-ice-cream-sandwich
我有一个EditText给用户评论.现在我想输入限制将是500字.这意味着用户最多可以写500条评论.我该如何实现呢?请帮我.
我想将arraylist限制为50.但我不知道如何.
这是我的代码Object1.java
public class Object1 {
public String seat_no, id;
public Object1(String seat_no, String id) {
this.seat_no = seat_no;
this.id = id;
}
}
Run Code Online (Sandbox Code Playgroud)
main.java
private ArrayList<Object1> list;
list = new ArrayList<Object1>();
Run Code Online (Sandbox Code Playgroud) android ×9
android-4.0-ice-cream-sandwich ×1
arraylist ×1
java ×1
launcher ×1
layout ×1
mobile ×1
parsing ×1
video ×1
viewflipper ×1