昨天(17-10-2014)我已经更新了Android SDK和support-library-v4.jar我的应用程序,现在我得到了相关的弃用警告ActionBarDrawerToggle,阅读文档似乎我必须使用ActionBarDrawerTogglein support-library-v7.appcompact.jar.
这里我的活动的一些部分可能是相关的:
import android.app.ActionBar;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class MyActivity extends FragmentActivity {
private ActionBar bar;
private CustomActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawer;
private ListView mDrawerList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infoviewer);
bar = this.getActionBar();
bar.setDisplayHomeAsUpEnabled(true);
bar.setHomeButtonEnabled(true);
bar.setDisplayShowTitleEnabled(false);
mDrawer = …Run Code Online (Sandbox Code Playgroud) 我有这个方法:
public String getRealPathFromURI(Uri contentUri) {
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,编译器向我显示了一个问题:
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
Run Code Online (Sandbox Code Playgroud)
因为managedQuery()已弃用.
如何在不使用的情况下重写此方法managedQuery()?
我必须编辑一个具有自定义视图的软件,当我尝试编辑布局xml时,Eclipse说我:
在Eclipse中显示时,在自定义视图中使用View.isInEditMode()来跳过代码
但我不知道应用程序中必须使用isIndditMode()的方式和位置
我的xml文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff000000"
>
<TextView
android:id="@+id/result"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="32dip"
android:scrollbars="none"
android:lines="1"
android:freezesText="true"
android:textColor="@color/result"
/>
<EditText
android:id="@+id/input"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="28dip"
android:scrollbars="none"
android:singleLine="true"
android:autoText="false"
android:imeOptions="flagNoEnterAction|flagNoExtractUi"
/>
<ListView
android:id="@+id/history"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:cacheColorHint="#ff000000"
android:choiceMode="singleChoice"
android:scrollbarStyle="outsideInset"
android:scrollbars="none"
/>
<calculator.GraphView
android:id="@+id/graph"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:visibility="gone"
/>
<include layout="@layout/keyboard" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的GraphView是
public class GraphView extends View implements Grapher,
ZoomButtonsController.OnZoomListener,
TouchHandler.TouchHandlerInterface {
private int width, height;
private Matrix matrix = …Run Code Online (Sandbox Code Playgroud) 我想Bitmap在字符串中编码和解码对象base64.我使用的是Android API10,
我试过使用这种形式的方法来编码a,但没有成功Bitmap.
public static String encodeTobase64(Bitmap image) {
Bitmap immagex=image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
Log.e("LOOK", imageEncoded);
return imageEncoded;
}
Run Code Online (Sandbox Code Playgroud) 我已将Android Studio更新为版本3,现在似乎无法编译我之前编译的项目而没有错误.
错误消息如下
错误:错误:commons-logging定义与Android现在提供的类冲突的类.解决方案包括查找没有相同问题的更新版本或替代库(例如,对于httpclient使用HttpUrlConnection或okhttp),或者使用jarjar之类的东西重新打包库.[DuplicatePlatformClasses]
依赖是
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
compile 'com.google.firebase:firebase-core:11.4.2'
}
Run Code Online (Sandbox Code Playgroud)
和错误似乎是由
compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
Run Code Online (Sandbox Code Playgroud)
我已经使用了exclude module: 'httpclient'
为什么它不编译?这是Android Studio 3和\或包含com.android.tools.build:gradle:3.0.0插件的错误还是我遗漏了什么?使用以前的版本编译完全相同的项目没有问题.
android android-studio android-gradle-plugin android-studio-3.0 android-gradle-3.0
运用
gcc -m32 myprog.c
Run Code Online (Sandbox Code Playgroud)
应该在32位版本中编译该文件myprog.c.
不幸的是我收到此错误:
In file included from /usr/include/stdio.h:27:0,
from myprog.c:1:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
#include <sys/cdefs.h>
Run Code Online (Sandbox Code Playgroud)
我怎么能解决这个问题?
如果我不使用-m32它工作,但使用64位指令.
如果我试着写
Car myCarObject=getCar();
Intent details = new Intent(Start.this, DetailsCar.class);
details.putExtra("Car", myCarObject);
startActivity(details);
Run Code Online (Sandbox Code Playgroud)
Eclipse向我展示了一行编译错误"方法放置额外对于类型Intent是不明确的"
details.putExtra("Car", myCarObject);
Run Code Online (Sandbox Code Playgroud)
如果我使用代码
Car myCarObject=getCar();
ArrayList<Car> parcelableExtra = new ArrayList<Car>();
parcelableExtra.add(myCarObject);
Intent details = new Intent(Start.this, DetailsCar.class);
details.putExtra("Car", parcelableExtra);
startActivity(dettagli);
Run Code Online (Sandbox Code Playgroud)
我尝试在目标Intent中加载额外的代码
ArrayList<Car> parcelableExtra = new ArrayList<Car>();
parcelableExtra = (ArrayList<Car>) getIntent().getExtras().getParcelable("Car");
Car c=parcelableExtra.get(0);
Run Code Online (Sandbox Code Playgroud)
我收到了这个警告
12-14 05:30:07.669: W/Bundle(19823): Key Car expected Parcelable but value was a java.util.ArrayList. The default value <null> was returned.
12-14 05:30:07.679: W/Bundle(19823): Attempt to cast generated internal exception:
12-14 05:30:07.679: W/Bundle(19823): java.lang.ClassCastException: java.util.ArrayList
12-14 …Run Code Online (Sandbox Code Playgroud) 我有ScrollView一个Datepicker
在以前的Android版本中,Datepicker是这样的:

我可以滚动Datepicker日,月,年的单个元素没有问题
在Android Lollipop API level 21 Material中,Datepiker以这种方式显示:


如果我点击月份显示日历视图而我无法更改月份,我只能选择当天.如果我尝试编辑年份显示年份滚动条,但如果我尝试滚动它,则包含datepicker的整个布局将滚动,而不仅仅是日期.
calendarViewShown=false
Run Code Online (Sandbox Code Playgroud)
似乎被忽视了
我怎么能解决这个问题???
android datepicker android-datepicker datepickerdialog android-5.0-lollipop
我想得到从图库加载或从相机中拾取的图像的图像扩展名(例如"jpg","png","bmp"ecc.).
我已经使用此表单中的方法从库中加载图像
private static final int SELECT_PICTURE_ACTIVITY_REQUEST_CODE = 0;
....
private void selectPicture() {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, SELECT_PICTURE_ACTIVITY_REQUEST_CODE);
}
....
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch (requestCode) {
case SELECT_PICTURE_ACTIVITY_REQUEST_CODE:
if (resultCode == RESULT_OK) {
Uri selectedImage = imageReturnedIntent.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if (cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
.........
} …Run Code Online (Sandbox Code Playgroud) 我有这个代码
itemizedOverlay = new MyItemizedOverlay(drawable,this);
itemizedOverlay.setGestureDetector(new GestureDetector(new MyGestureDetecor()));
Run Code Online (Sandbox Code Playgroud)
但在Eclipse中new GestureDetector标记为Deprecated.
我想避免使用已弃用的方法.
我怎么能解决这个问题?
什么是不弃用的表格?
android ×9
deprecated ×2
android-maps ×1
base64 ×1
bitmap ×1
c ×1
c++ ×1
datepicker ×1
java ×1
linux ×1
parcelable ×1
ubuntu ×1