我正在使用IntelliJ IDEA 14,我想将src外的文件添加到JAR文件中.这是我目前的项目结构.
我想将layout.txt和saveddata.txt添加到JAR文件可执行文件中.我一直在谷歌上搜索一段时间无法找到解决方案
如果你需要看我的代码.这就是我读文件的方式
private Path layoutPath = Paths.get("resources/layout.txt");
content = new String(Files.readAllBytes(layoutPath));
Run Code Online (Sandbox Code Playgroud)
这是我的项目结构
我正在尝试覆盖我在gradle文件中使用的库的minSDK.以下是错误消息
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 13 declared in library [com.intuit.sdp:sdp-android:1.0.2] C:\Users\{User_Name}\{App_Name}\app\build\intermediates\exploded-aar\com.intuit.sdp\sdp-android\1.0.2\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="com.intuit.sdp" to force usage
Run Code Online (Sandbox Code Playgroud)
一个快速的谷歌告诉我在Mainfest中使用overrideLibrary.所以我在AndroidManifest.xml中添加以下行
<uses-sdk
android:minSdkVersion="10"
tools:overrideLibrary="com.intuit.sdp" />
Run Code Online (Sandbox Code Playgroud)
然后,我清理并重建项目,但它仍然显示与以前完全相同的错误.
我正在开发一个基于软键盘样本的键盘.我想知道如何创建自己的建议.我在Candidate View Class中看到了setSuggestion方法,但在该方法的参数中,我看到一个字符串列表(Suggestions)被传递给this方法.我的问题是我是否必须为setSuggestion方法中的建议或传递字符串数组的其他方法创建自己的算法.
我使用JourneyApp的BarCode扫描仪库设置了条形码扫描仪
我添加了依赖项,就像在库的自述文件中一样.
然后,我在我的主要活动中设置了一个BarCode View
main_activity.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<com.journeyapps.barcodescanner.BarcodeView
android:id="@+id/barcode_scanner"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.journeyapps.barcodescanner.BarcodeView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我将MainActivity.java保留为默认值.这是OnCreate方法
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
Run Code Online (Sandbox Code Playgroud)
我也在我的清单中添加了相机权限.
当我在手机上运行应用程序时.BarCodeView仅显示黑屏.我在这里做错了吗?
我在Adapter内部编写了一个监听器接口GridView
来获取所选图像的图像路径。说的MainActivity
是投掷NotSerializableException
。让 Activity Serialize 成为可能并不是一个好的做法。我在创建 Fragment 实例时将侦听器传递给 Bundle。它工作完美,但每当 Activity 进入暂停状态时就会崩溃。(当我单击菜单(或)主页按钮时)
错误的 LogCat:
\n\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: FATAL EXCEPTION: main\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: Process: PACKAGE_NAME, PID: 16903\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = PACKAGE_NAME.activities.MainActivity$StickerSelectListener)\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: at android.os.Parcel.writeSerializable(Parcel.java:1388)\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: at android.os.Parcel.writeValue(Parcel.java:1335)\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: at android.os.Parcel.writeArrayMapInternal(Parcel.java:638)\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)\n 11-03 12:37:34.556 16903-16903/PACKAGE_NAME E/AndroidRuntime: at android.os.Bundle.writeToParcel(Bundle.java:1096)\n 11-03 12:37:34.556 …
Run Code Online (Sandbox Code Playgroud) 我正在使用新的Android支持设计库.我已经在Android Developer Blogspot上关注了演示,除了我使用RecyclerView的片段而不是将它们放在同一个xml中.
这是我的activity_main.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout"
>
<android.support.design.widget.CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/toolbar"/>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<fragment
android:id="@+id/navigation_drawer"
android:layout_marginTop="?android:attr/actionBarSize"
android:name="aungkyawpaing.yangonuniversity.Fragments.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start|left"
tools:layout="@layout/fragment_navigation_drawer"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
这是toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
And this is the fragment where it has RecyclerView
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/department_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Run Code Online (Sandbox Code Playgroud)
我在gradle中添加了最新的支持库依赖项.我看到另一个人说它不起作用,因为他在片段中使用了列表视图,但我正在使用RecyclerView.
在 Gradle 6.1.1 上,如何为 android 项目添加 sourceSets?
其他问题的答案不再有效,getByName("name")
返回错误SourceSet with name 'main' not found.
官方文档说使用
sourceSets {
main {
java {
srcDir("thirdParty/src/main/java")
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,有超过 20 个 main 必须导入,我不确定哪一个是正确的。
但问题是它只是在图像视图边界内移动和缩放。我想要的是用两个手指手势调整图像视图的大小。它应该根据收缩变大或变小。我整天都在谷歌上搜索调整大小,但无法弄清楚。所有的教程只指出我在 ImageView 内部缩放而不是调整大小。以下是我从博客中生成的自定义图像视图代码。
public class InteractableImageView extends ImageView implements View.OnTouchListener {
private static final int INVALID_POINTER_ID = -1;
private ScaleGestureDetector mScaleDetector;
private float mScaleFactor = 1.f;
private int mActivePointerId = INVALID_POINTER_ID;
private float mPosX;
private float mPosY;
private float mLastTouchX;
private float mLastTouchY;
public InteractableImageView(Context context) {
this(context, null, 0);
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
}
public InteractableImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
}
public …
Run Code Online (Sandbox Code Playgroud)