我正在尝试将我的文件保存到以下位置,
FileOutputStream fos = new FileOutputStream("/sdcard/Wallpaper/"+fileName);
但是我得到了异常java.io.FileNotFoundException
但是,当我把路径保存"/sdcard/"
起来的时候.
现在我假设我无法以这种方式自动创建目录.
有人可以建议如何创建directory and sub-directory
使用代码吗?
我给我的布局中嵌入的webview客户端提供以下方法调用
wv.loadData("<html><body bgcolor=\"Black\"></body></html>","text/html", "utf-8");
当我在设备上运行它时,它在右侧显示一个白色垂直条.我通过使用固定白色的东西,webview.setBackgroundColor(Color.BLACK);
但我想完全删除它
以下是我的布局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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<WebView android:id="@+id/wv1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
有什么建议??
我想在我的应用程序按钮中添加触觉反馈,并以编程方式控制它们以显示按钮状态(启用和禁用).默认触觉反馈设置器仅适用于长按.如何使其适用于简单的按钮点击.
有没有办法对触摸移动等事件进行触觉反馈?
我试图将Applozic聊天平台集成到我的Ionic 2项目中,我希望将其导出到Web,Android和iOS.使用示例作为基础并为Javascript集成过程创建applozic.d.ts和applozichv.js.
applozic.d.ts
interface AppLozicStatic {
initPlugin(): any;
}
declare var AppLozic : AppLozicStatic;
export = AppLozic;
Run Code Online (Sandbox Code Playgroud)
applozichv.js
(function () {
var root = this;
var AppLozic = function (obj) {
if (obj instanceof AppLozic) return obj;
if (!(this instanceof AppLozic)) return new AppLozic(obj);
// this.EXIFwrapped = obj;
};
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = AppLozic;
}
exports.AppLozic = AppLozic;
} else …
Run Code Online (Sandbox Code Playgroud) 林移植现有应用摇篮构建系统,并得到了以下错误,而从做一个构建命令行
error: No resource identifier found for attribute 'ignore_vertical_scroll' in package 'com.example.dummyapp'
现在'ignore_vertical_scroll'
是在布局中attrs.xml
使用它定义的自定义属性abc:ignore_vertical_scroll="true"
xmlns:abc="http://schemas.android.com/apk/res-auto"
我到目前为止所读到的是,这个URI是在ADT 17.0中添加的,以缓解自定义组件中的包名称问题.不确定这是如何在gradle中翻译的.
希望使用一个主要的中心操作按钮修改底部导航栏,该按钮改变导航栏本身的形状,或者像这样的弧形
或者底部导航中的一个驼峰包围着它周围的中心按钮。
如果我必须延长,我很好,BottomNavigationView
但我不知道从哪里开始。
我发现了这个类似的问题,但这不是我想要解决的确切问题。
我能够使用以下代码成功记录屏幕上触摸的两个手指的坐标:
case MotionEvent.ACTION_MOVE:
Log.d("TOUCH", "test ACTION MOVE" + event.getPointerCount());
Log.d("TOUCH", "test ACTION MOVE ID" + event.getPointerId(0) + " "+event.getPointerId(1));
if(event.getPointerCount()==3)
{
x0 = (int) event.getX(event.getPointerId(0));
y0 = (int) event.getY(event.getPointerId(0));
x1 = (int) event.getX(event.getPointerId(1));
y1 = (int) event.getY(event.getPointerId(1));
x2 = (int) event.getX(event.getPointerId(2));
y2 = (int) event.getY(event.getPointerId(2));
Log.d("TOUCH", "test ACTION DOWN " + " values = " + x0 + " " + y0 + " "
+ x1 + " " + y1+ " "+x2 + " " + y2);
} …
Run Code Online (Sandbox Code Playgroud) 我有一个postgreSql数据库,由一个Android应用程序通过Web服务操作.我想知道为我的应用程序制作离线模式的最佳方法是什么.
我的第一个想法是在设备无法访问Web时使用sqlite本地数据库
我想知道是否有现有的工具,一旦设备可以访问web ,就可以使现有的postgres数据库更容易同步
当我只用Volley提出请求时,一切顺利,我的StringRequest转到onResponse.
但当我切换到Volley + Okhttp组合时,我的请求通过,我收到与以前相同的响应,但后来我收到以下错误消息:
E/Volley? [122319] BasicNetwork.performRequest: Unexpected response code 200 for <my request url>
java.io.IOException: closed
com.android.volley.NetworkError: java.io.IOException: closed
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:182)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
Caused by: java.io.IOException: closed
at okio.RealBufferedSource$1.read(RealBufferedSource.java:345)
at java.io.InputStream.read(InputStream.java:162)
at com.android.volley.toolbox.BasicNetwork.entityToBytes(BasicNetwork.java:254)
at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:130)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:114)
我使用这个https://gist.github.com/bryanstern/4e8f1cb5a8e14c202750为我的OkHttpStack for Volley.
我想为我的所有活动屏幕创建一个静态选项菜单.我不想onCreateOptionsMenu()
在每个活动中覆盖.
由于Menu
类是具有大量方法的接口,因此很难创建实现类的静态对象.
还有其他方法吗?
我正在尝试构建一个应用程序,尝试在开始视频录制之前自动对焦相机.直接使用MediaRecorder
不会自动对焦相机.为此我使用Camera
和使用回调我可以自动对焦它.但是提供这个实例给MediaRecorder
了我很多问题.以下是用于录制的代码
public boolean startRecording()
{
try
{
mCamera.unlock();
mediaRecorder = new MediaRecorder();
mediaRecorder.setCamera(mCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
CamcorderProfile profile = CamcorderProfile
.get(CamcorderProfile.QUALITY_LOW);
mediaRecorder.setProfile(profile);
mediaRecorder.setMaxDuration(maxDurationInMs);
File file = new File(outputFile);
if (file.exists())
file.delete();
file = new File(outputFile);
try
{
file.createNewFile();
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
Log.e("Deepak", "*** first catch ***");
}
mediaRecorder.setOutputFile(outputFile);
mediaRecorder.setPreviewDisplay(mHolder.getSurface());
mediaRecorder.setMaxFileSize(maxFileSizeInBytes);
mediaRecorder.prepare();
mediaRecorder.start();
return true;
}
catch (IllegalStateException e)
{
Log.e(TAG, e.getMessage());
e.printStackTrace();
return false;
}
catch (IOException …
Run Code Online (Sandbox Code Playgroud) 我解释的事情非常糟糕,我会努力做到最好:)
我试图使用Tabhost并在每个选项卡中显示列表片段.
[tabview中的ListFragments]:
这是它的外观.
单击列表元素后,将调用另一个片段以显示详细信息,如下所示.[在列表元素上单击]:
有两个问题.
当我回到标签视图并单击列表时,它会显示:
"java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread
.[in ListView(16908298, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)]
"TabView xml:
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp" …
Run Code Online (Sandbox Code Playgroud)我正在尝试在我的RecyclerView中使用以下代码使用可绘制着色
Drawable likeDrawable = ContextCompat.getDrawable(getActivity(), R.drawable.ic_thumb_up);
Drawable likeWrappedDrawable = DrawableCompat.wrap(likeDrawable);
DrawableCompat.setTint(likeWrappedDrawable,ContextCompat.getColor(getActivity(), android.R.color.white));
holder.ivLike.setImageDrawable(likeWrappedDrawable);
Run Code Online (Sandbox Code Playgroud)
现在,所有这些工作都在onBindViewHolder
RecyclerView Adapter的中完成。
我会根据该列表项的状态在三种颜色之间更改此色调。对于Lolipop及更高版本,这一切正常,但在此版本以下,列表项目的颜色是无法预测的。有时它显示正确的颜色,但刷新列表时有时会更改为其他颜色。
Anything im doing wrong here or the tinting thing on pre-lollipop is still unusable in this particular case?
Update
Including the code from my onBindViewHolder
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
...
Drawable likeDrawable =
ContextCompat.getDrawable(getActivity(), R.drawable.ic_thumb_up);
Drawable likeWrappedDrawable = DrawableCompat.wrap(likeDrawable);
holder.tvLikeCount.setTextColor(ResUtil.getColor(R.color.light_font,
getActivity()));
DrawableCompat.setTint(likeWrappedDrawable,
ContextCompat.getColor(getActivity(), android.R.color.white));
if (tweetModel.isFavorited()) {
DrawableCompat.setTint(likeWrappedDrawable,
ContextCompat.getColor(getActivity(), android.R.color.holo_blue_light));
}
holder.ivLike.setImageDrawable(likeWrappedDrawable);
}
Run Code Online (Sandbox Code Playgroud) android ×12
android-file ×1
applozic ×1
build.gradle ×1
gradle ×1
ionic2 ×1
javascript ×1
jquery ×1
list ×1
mobile ×1
multi-touch ×1
offline-mode ×1
okhttp ×1
postgresql ×1
sqlite ×1
tabview ×1
vibration ×1