小编ENG*_*618的帖子

CoordinatorLayout AppBarLayout背后的内容

我正在为我的应用创建设置活动/布局.我有一个CoordinatorLayoutAppBarLayoutToolbar,那么下面这包括content_settings.xml.当内容加载时,.xml文件位于应用栏后面.

我正在使用相同的设置加载主要内容,它工作正常,但由于某种原因无法在"设置"部分正确呈现.

activity_settings.xml

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_setting" />
Run Code Online (Sandbox Code Playgroud)

content_settings.xml只是一个FrameLayout被a替换的PreferenceFragment

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/settings_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

xml android android-toolbar android-coordinatorlayout

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

PFObject无法转换为自定义子类

在最近更新swift编译器更新之前,此代码工作正常.我已经纠正了所有明显的错误,但由于某种原因,当我运行应用程序时,它会在for in loop尝试强制转换[AnyObject]到我的自定义Memory类时崩溃.

日志和错误显示如下:

Has connectivity
Successfully retrieved 8 memories.
current memory: <Memories: 0x170120960, objectId: AO3EvPFob4, localId: (null)> {
ACL = "<PFACL: 0x174047e30>";
Date = "3915-04-08 05:00:00 +0000";
Guests = 4;
Title = test4;
}
Could not cast value of type 'PFObject' (0x100130bc0) to 'MemoryVault.Memory' (0x10012fa00).
Run Code Online (Sandbox Code Playgroud)

所以我知道我正在从Parse中检索到8个正确的记忆,而且当前的记忆是正确的......它只是不会施放它.

代码:

    if (NetworkValidator.hasConnectivity()){ // Has internet connectivity
        println("Has connectivity")
        Memory.memoryQuery().findObjectsInBackgroundWithBlock{
            (objects: [AnyObject]?, error: NSError?) -> Void in
            if error == nil {
                // The find succeeded.
                 println("Successfully …
Run Code Online (Sandbox Code Playgroud)

casting parse-platform swift

6
推荐指数
1
解决办法
1196
查看次数

在startIntentSenderForResult之后没有调用OnActivityResult

我正在使用"使用Google登录"的启动页面.当用户拥有多个帐户时...在他们选择要登录的帐户后,我正在尝试启动应用程序主要活动,但由于某种原因onActivityResult,我的片段中从未调用过.

我是Activity,我调用onActivityResult并让它调用super以便片段可以处理它,但它永远不会触发.

有什么建议?

这是有问题的片段:

package com.garciaericn.goodeats.login;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.garciaericn.goodeats.R;
import com.garciaericn.goodeats.helpers.CheckConnection;
import com.garciaericn.goodeats.main.FavoritesActivity;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.plus.Plus;

public class LoginFragment extends Fragment implements View.OnClickListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {

    public static final String TAG = "com.garciaericn.goodeats.login.LoginFragment.TAG";

    /* Request code used to invoke sign in user interactions. */
    private static final int RC_SIGN_IN = 0;
    private …
Run Code Online (Sandbox Code Playgroud)

android android-fragments onactivityresult

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

操作栏项目单击片段中的处理程序

我有一个简单的2活动应用程序.主活动填充listFragment,第二个活动填充带有字段的片段,以将自定义对象(列表项)添加到主活动.

在第二个活动中,我在操作栏中有一个"保存"图标.我正在试图弄清楚如何在片段中单击此按钮,因此我可以打包textFields并通过界面将其传递回活动.

我试图覆盖,onOptionItemSelected但它没有击中.我该怎么处理?

android android-fragments

3
推荐指数
1
解决办法
4772
查看次数

在Parse查询后,RecyclerView notifyDataSetChanged无法正常工作

在查询Parse获取某些数据后,我正在尝试更新我的Recycler视图.在done我调用的查询方法中notifyDataSetChagned,但从不显示列表

package com.garciaericn.t2d.fragments;

public class DevicesCardViewFragment extends Fragment implements View.OnClickListener {

    private OnFragmentInteractionListener mListener;
    private BatteryHelper mBatteryHelper;
    Intent mBatteryStatus;

    private RecyclerView mRecyclerView;
    private DeviceAdapter mAdapter;
    private RecyclerView.LayoutManager mLayoutManager;
    private List<Device> mDevices;

    public DevicesCardViewFragment() {
        // Required empty public constructor
        mDevices = new ArrayList<Device>();
    }

    public static DevicesCardViewFragment newInstance() {
        // Bundle parameters is necessary

        return new DevicesCardViewFragment();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Get arguments
        getDevices();

        mBatteryHelper = new BatteryHelper(getActivity());

        IntentFilter intentFilter = …
Run Code Online (Sandbox Code Playgroud)

android parse-platform android-recyclerview

3
推荐指数
1
解决办法
8120
查看次数

Swift,如何设置Parse默认ACL

我正在尝试在AppDelegate中设置默认ACL.据它说明使用的文件......

PFACL.setDefaultACL(PFACL.ACL(), withAccessForCurrentUser: true)
Run Code Online (Sandbox Code Playgroud)

但是,当我使用它时,我在读取的行上出现错误...

'ACL()' is unavailable: use object construction 'PFACL()'
Run Code Online (Sandbox Code Playgroud)

acl parse-platform swift

3
推荐指数
1
解决办法
951
查看次数

如何获取当前电池电量百分比?

我正在创建一个电池监视器应用程序,并且尝试显示当前的电池百分比。我有一个广播接收器,正在监听...

<action android:name="android.intent.action.BATTERY_CHANGED" />
Run Code Online (Sandbox Code Playgroud)

在接收器中我有以下代码。

int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

currentBatteryLevel = level / (float) scale;

Toast.makeText(context, "Current battery level: " + Float.toString(currentBatteryLevel) + "%", Toast.LENGTH_SHORT).show();
Run Code Online (Sandbox Code Playgroud)

由于某种原因,结果总是Current battery level: 1.0%......我哪里出错了?

编辑:

接收者在清单中注册为...

<receiver android:name=".PowerMonitorReceiver">
    <intent-filter>
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
        <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
        <action android:name="android.intent.action.BATTERY_LOW" />
        <action android:name="android.intent.action.BATTERY_OKAY" />
        <action android:name="android.intent.action.BATTERY_CHANGED" />
    </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

我的接收器是...

com.garciaericn.t2d 包;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.BatteryManager;
import android.util.Log;
import android.widget.Toast;

public class PowerMonitorReceiver extends BroadcastReceiver { …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver batterylevel

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

将"字符串编号"转换为数字

我正在创建一个库并尝试将一个字符串发送到该函数并将其作为数字返回,同时创建一个条件以确定在转换之前发送到函数中的字符串是否为数字.

var strNum = function(val){
    if (!isNan(val)){
        console.log('This is a string that can be converted')
        parseInt(val)
        return val
    }else{
        console.log ('This sting is not a "number"');
    }
};
Run Code Online (Sandbox Code Playgroud)

这就是我所拥有的,但在调试时我得到一个错误 "ReferenceError:isNan未定义如果(val =!isNan(val)){" 我不知道为什么它不起作用!

有什么想法吗?

javascript

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