小编Pre*_*exx的帖子

拆分字符串| java中的分隔符

我有一个像这样的字符串: 1|"value"|;

我想拆分该字符串并选择|作为分隔符.

我的代码看起来像这样:

String[] separated = line.split("|");
Run Code Online (Sandbox Code Playgroud)

我得到的是一个包含所有字符作为一个条目的数组:

separated[0] = ""
separated[1] = "1"
separated[2] = "|"
separated[3] = """
separated[4] = "v"
separated[5] = "a"
...
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么?
我不能拆分一个字符串|吗?

java string split

32
推荐指数
4
解决办法
8万
查看次数

将焦点更改为EditText Android

我的Activity上有2个EditText,并设置maxLength为5.

现在我想把焦点设置为editText2,如果达到5的长度editView1...

我尝试过:

editView1.setOnKeyListener(new OnKeyListener() {
    @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        if(editView1.getText().length() == 5)
            editView2.requestFocus();
        return false;
    }
});
Run Code Online (Sandbox Code Playgroud)

但它不会起作用..

android focus android-edittext

19
推荐指数
1
解决办法
5万
查看次数

加载位图时出现内存不足错误

我有一个Android应用程序与3 acitivtys:

A1 - 开始 - > A2 - 开始 - > A3 - 完成他的过程:开始 - > A1

(所以我不"完成();"一个应用程序.我用"startActivity(..);"用户交互后的整个时间开始下一个活动)

所以这3个活动中有一个循环.在每个活动中,我显示位于SD卡上的3-9张图片,我使用以下功能加载:

try
{
    Uri selectedImageURI = Uri.parse(strImagePath);
    File imgFile = new  File(getRealPathFromURI(selectedImageURI, c));
    Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
    ivTmp.setImageBitmap(myBitmap);
}catch (Exception e)
{
    return null;
}
Run Code Online (Sandbox Code Playgroud)

这一切都有效.但有时候(通过我的活动循环几次后),我的应用程序崩溃了..

Logcat告诉我:

01-16 13:42:15.863: DEBUG/dalvikvm(23161): GC_BEFORE_OOM freed 10K, 9% free 59019K/64400K, paused 29ms, total 30ms
01-16 13:42:15.863: ERROR/dalvikvm-heap(23161): Out of memory on a 8018704-byte allocation.
01-16 13:42:15.863: ERROR/AndroidRuntime(23161): FATAL EXCEPTION: main
        java.lang.OutOfMemoryError
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
        at …
Run Code Online (Sandbox Code Playgroud)

android bitmap out-of-memory

17
推荐指数
1
解决办法
2万
查看次数

如何在android中实现更改日志?

对于我的应用程序,我想实现更改日志,但不知道如何(哪个概念).

我想,安装新版本的应用程序后,更新日志会弹出一次.听起来很简单,但我不知道.:/

显示我的更改日志的对话框已经存在,我只想知道如何在更新后显示它.

谢谢你的提示.

Prexx

android changelog

11
推荐指数
2
解决办法
5064
查看次数

IntelliJ:让GridLayout工作

我尝试在我的应用程序中使用GridLayout,但它不会工作.我使用了这个教程:IntelliJ和android.support.v7.widget.GridLayout

但它仍然无法运作.

我收到以下错误:

error: No resource identifier found for attribute 'columnCount' in package 'android'
error: No resource identifier found for attribute 'rowCount' in package 'android'
Run Code Online (Sandbox Code Playgroud)

还有什么提示?

编辑:使用我的实际XML:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:grid="http://schemas.android.com/apk/res-auto"
              android:layout_width="350dp"
              android:layout_height="fill_parent"
              android:orientation="vertical">

    <EditText android:layout_height="wrap_content"
              android:layout_width="fill_parent"
              android:cursorVisible="false"
              android:id="@+id/txtName"/>


    <android.support.v7.widget.GridLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            grid:columnCount="3"
            grid:rowCount="2">

        <TextView   
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1,1" />
     
    </android.support.v7.widget.GridLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android grid-layout

11
推荐指数
1
解决办法
4304
查看次数

不同的退出/输入动画

我想为不同的活动定义两个窗口动画样式.

这是我到目前为止:

表现:

<application
    ...>
    <activity
        android:name=".MainActivity"
        android:screenOrientation="portrait"
        android:theme="@style/A" />
    <activity
        android:name=".SecondActivity"
        android:screenOrientation="portrait"
        android:theme="@style/B" />
</application>
Run Code Online (Sandbox Code Playgroud)

Styles.xml:

<style name="A" parent="AppTheme">
    <item name="android:windowAnimationStyle">@style/CustomActivityAnimation</item>
</style>

<style name="CustomActivityAnimation" parent="@android:style/Animation.Activity">
    <item name="android:activityOpenEnterAnimation">@anim/bottom_in</item>
    <item name="android:activityOpenExitAnimation">@anim/scale_out</item>
    <item name="android:activityCloseEnterAnimation">@anim/scale_in</item>
    <item name="android:activityCloseExitAnimation">@anim/bottom_out</item>
</style>


<style name="B" parent="@style/Theme.AppCompat.Light.Dialog">
    <item name="android:windowAnimationStyle">@style/CustomDialogAnimation</item>
</style>

<style name="CustomDialogAnimation" parent="@android:style/Animation.Dialog">
   <item name="android:windowEnterAnimation">@anim/dialog_in</item>
   <item name="android:windowExitAnimation">@anim/dialog_out</item>
</style>
Run Code Online (Sandbox Code Playgroud)

我想要实现的是:

具有样式的活动之间的转换A应使用中定义的动画CustomActivityAnimation.

具有样式的活动B被设置为对话框,并且应该定义其他过渡动画CustomDialogAnimation.

我的问题:

android:windowExitAnimation从风格CustomDialogAnimation,当我从风格接近的活动从来没有使用过B.取而代之的android:activityCloseExitAnimation是风格CustomActivityAnimation.

任何提示?

animation android

5
推荐指数
1
解决办法
457
查看次数

房间交界处Pojo

我尝试在 pojo 中获取 N:M 数据库实体。

以下是实体:

人:

@Entity(
    tableName = "person_table",
    indices = [Index("person_id")]
)
class Person() {
    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "person_id")
    var id: Long = 0
}
Run Code Online (Sandbox Code Playgroud)

车:

@Entity(
    tableName = "car_table",
    indices = [Index("car_id")]
)
class Car() {
    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "car_id")
    var id: Long = 0
}
Run Code Online (Sandbox Code Playgroud)

和连接实体:

@Entity(
    tableName = "person_car_join",
    primaryKeys = ["fk_person_id", "fk_car_id"],
    indices = [
        Index("fk_person_id"),
        Index("fk_car_id")
    ],
    foreignKeys = [
        ForeignKey(
            entity = Person::class,
            childColumns = arrayOf("fk_person_id"),
            parentColumns …
Run Code Online (Sandbox Code Playgroud)

android many-to-many android-room

4
推荐指数
1
解决办法
2404
查看次数

更改街景< - >卫星Google地图Android

我想通过menubutton在StreetView和Satellite之间切换我的GoogleMaps视图.

这是我的代码:

public boolean onCreateOptionsMenu(Menu menu){

    menu.add(0, 0, 0, "StreetView");
    menu.add(0, 0, 1, "Satellite");

    return true;
}

public boolean onOptionsItemSelected (MenuItem item){

    switch (item.getItemId()){
        case 0:
            mapView.setStreetView(true);
        return true;

        case 1 :
            mapView.setSatellite(true);
        return true;

    }

    return false;
}
Run Code Online (Sandbox Code Playgroud)

不会工作..我错了什么?

谢谢,prexx

maps android view

2
推荐指数
2
解决办法
1万
查看次数

Highchart 库和响应式设计

我使用图书馆highcharts并在他们的文档中尝试了这个例子:

https://www.highcharts.com/demo/responsive

问题是,我必须配置多个响应规则来处理多个最大宽度。但这似乎不起作用。responsive.rules图表配置中的元素是一个数组,所以我假设我可以定义多个规则,如下所示:

var chartConfig = {
chart: {
    type: 'column'
},
[...]// Default config here for Tablet/PC
,
    responsive: {
        rules: [{
            condition: {
                maxWidth: 273
            },
            chartOptions: {
                [...]
                // Config for max-width 375 devices (bar chart width is 273 on my page)
            }
        },
        {
            condition: {
                maxWidth: 312
            },
            chartOptions: {
                [...]
                // Config for max-width 420 devices (bar chart width is 312 on my page)
            }
        }]
    }
Run Code Online (Sandbox Code Playgroud)

但它不会工作。该库仅使用最后一个配置。任何人都知道如何使用此库处理多个响应式配置?

javascript charts highcharts responsive-design

2
推荐指数
1
解决办法
336
查看次数

检查迭代器是否引用列表中的项

我只想检查迭代器是否指向列表中的对象.

什么是cmd?

谢谢.:)

SkyThe

编辑:

嗯,好吧,我试过了.现在有一个错误:"表达式:列表迭代器不可复制"

也许一些代码:

#include <list>
list<obj> list;
list<obj>::iterator it;

if(it != list.end()){ //here the error pops up when i debug
  vShowStatus();
}else{
  cout << "...";
}
Run Code Online (Sandbox Code Playgroud)

c++ iterator list

0
推荐指数
1
解决办法
2285
查看次数