我想存储图像SQLite DataBase.我试图用它来存储BLOB和String,在这两种情况下,它存储的图像,并可以获取,但是当我将其转换为Bitmap使用
BitmapFactory.decodeByteArray(...)它返回null.
我使用过这段代码,但它返回null
Bitmap bitmap = BitmapFactory.decodeByteArray(blob, 0, blob.length);
Run Code Online (Sandbox Code Playgroud) 我目前正在构建至少SDK10个,所以我必须使用该android-support-v7-appcompat库来实现ActionBar.我已经设置了ActionBar,但我想现在添加一个ListActivity,但是这需要扩展我的类而Java没有多个inheritance.我该怎么办?
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
getSupportActionBar().setIcon(R.drawable.ic_action_search);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
}
Run Code Online (Sandbox Code Playgroud) 我在PlaceAutocompleteApiPlay服务中使用,我想要做的是限制自动完成到特定的国家和城市.例如.所有城市都只能说是印度.我正在使用AutocompleteFilter这样做,但我不知道在哪里指定我想限制的国家/地区.
这是我的代码
List<Integer> autocompleteFilter = new ArrayList<>();
// autocompleteFilter.add(Place.TYPE_COUNTRY);
// autocompleteFilter.add(Place.TYPE_LOCALITY);
mAdapter = new PlaceAutocompleteAdapter(mContext,R.layout.layout_location_text,
mGoogleApiClient, BOUNDS, AutocompleteFilter.create(autocompleteFilter));
mTxtLocation.setAdapter(mAdapter);
mTxtLocation.setOnItemClickListener(mAutocompleteClickListener);
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
我的要求是将maven存储库的证书导入全局密钥库.
证书文件名为maven-cacert.cer.
我使用来自下面的命令C:\Program Files\Java\jdk1.6.0_20\bin\从cmd
keytool -importcert -trustcacerts -alias c:\maven-cacert.cer -file c:\maven-cacert.cer.der -keystore $JAVA_HOME\jre\lib\security\cacerts
Run Code Online (Sandbox Code Playgroud)
因为maven-cacert.cer文件在C目录中
按下输入后,它要求输入密码,并在给出密码之后说它就像
keytool error: java.io.FileNotFoundException: $JAVA_HOME\jre\lib\security\cacerts (The system cannot find the path specified
Run Code Online (Sandbox Code Playgroud)
我也试过了
keytool -importcert -trustcacerts -alias c:\maven-cacert.cer -file c:\maven- cacert.cer.der -keystore \usr\java/jdk1.6.0_20/bin/java\jre\lib\security\cacerts
Run Code Online (Sandbox Code Playgroud)
但获得相同的输出
当cacerts文件在$JAVA_HOME\jre\lib\security\目录中时,请帮助我的命令出错.
我有一个SeekBar在RelativeLayout其宽度等于屏幕的宽度.
我申请layout_width="match_parent"了SeekBar但是它似乎在两侧保留了一些空的空间SeekBar以容纳拇指.
我也尝试过使用android:thumb="@null"拇指已经消失但不是侧面的空白空间.
我真的需要让SeekBar宽度与父母的宽度相匹配.有人可以帮我这个吗?也许我可以SeekBar在onMeasure()中创建一个自定义类并将宽度设置为父宽度.如果这是一个可能的解决方案,我不知道如何将父宽度传递给SeekBar类.
任何帮助表示赞赏.谢谢.
我正在使用GridLayoutManager(GLM)我的RecyclerView.在RecyclerView,我将填充CardViews,如何设置我在整个屏幕中GLM只渲染一个CardView?
如果我将跨度大小设置为1,则CardView每行渲染一个,而不是整个屏幕.
在Simple中,我想显示1 CardView占用两列和两行.怎么做到这一点?
我能够从我打开设备的摄像头Activity使用Intent,如下所示:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Uri fileUri = getOutputMediaFileUri();
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
cameraIntent.putExtra("android.intent.extras.CAMERA_FACING", 1);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
Run Code Online (Sandbox Code Playgroud)
我的问题是我Activity的设置为横向模式,因此当相机打开时,它也会以横向模式打开- 但我只需要在纵向模式下打开相机.
因此,请在使用Intent启动设备的相机时告诉我如何执行此操作.
谢谢...
我最近下载了一个新的ADT.每次保存我的项目后,它都会显示以下XML错误.但是当我清理它时,同样会消失.有没有永久的解决方案.
提前致谢.
<TextView
android:id="@+id/selectquantityprompt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="50dip"
android:layout_marginTop="2dip"
android:text="Select Quantity"
android:textSize="20sp"
android:textColor="#33b5e5"
android:paddingLeft="25dp" //error at this line
android:paddingTop="5dp"
android:paddingBottom="5dp"
/>
Run Code Online (Sandbox Code Playgroud)
在此行找到多个注释:
- Consider adding android:paddingStart="25dp" to better support right-to-left layouts
- When you define %1$s you should probably also define %2$s for right-to-left
Run Code Online (Sandbox Code Playgroud) 就像我的标题所说的那样,我正在寻找getActivity()我ActionBarActivity班上相当于我的课程Android project.
我想Activity在AsyncTask声明对象中传递一个参数,因为我Activity在自定义AsyncTask扩展类中使用了一个对象
这是我项目的一个示例最简单的代码
public class EventCreator extends ActionBarActivity {
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_even_creator);
View v = getLayoutInflater().inflate(R.layout.activity_even_creator,null);
this.context = this.getBaseContext();
final Button createButton = (Button)findViewById(R.id.createEventButton);
createButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AsyncTask<Void,Void,Boolean> eventCreatorSend = new SendEvents(/* here need activity object */);
eventCreatorSend.execute();
}
});
}
class SendEvents extends AsyncTask<Void,Void,Boolean> {
public Activity act;
SendEvents(Activity a) …Run Code Online (Sandbox Code Playgroud) android android-asynctask android-activity android-actionbaractivity
这是在Android Canvas中实现撤消和重做的代码,并且工作正常.
package com.example.canva;
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.MotionEvent;
import android.view.View;
public class MainView extends View {
private Canvas mCanvas;
private Path mPath;
private Paint mPaint;
private ArrayList<Path> paths = new ArrayList<Path>();
private ArrayList<Path> undonePaths = new ArrayList<Path>();
public MainView(Context context)
{
super(context);
setFocusable(true);
setFocusableInTouchMode(true);
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setColor(0xFFFFFFFF);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
mPaint.setStrokeWidth(6);
mCanvas = new Canvas();
mPath = new Path();
}
// im=BitmapFactory.decodeResource(context.getResources(),R.drawable.ic_launcher);
@Override
protected void onSizeChanged(int …Run Code Online (Sandbox Code Playgroud)