小编Den*_*tal的帖子

渲染问题渲染期间引发的异常:com/android/util/PropertiesMap

我最近将我的Android Studio更新为2.1.1,并且我注意到我的布局预览不再有效,所以当我检查时它显示一条消息说:

渲染问题

渲染期间引发的异常:com/android/util/PropertiesMap(Details)

当我点击详细信息时弹出一个消息窗口,消除此错误:

java.lang.NoClassDefFoundError: com/android/util/PropertiesMap
at com.android.layoutlib.bridge.android.BridgeContext.createStyleBasedTypedArray(BridgeContext.java:940)
at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:638)
at android.content.res.Resources_Theme_Delegate.obtainStyledAttributes(Resources_Theme_Delegate.java:71)
at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1436)
at android.widget.TextView.<init>(TextView.java:761)
at android.widget.TextView.<init>(TextView.java:704)
at android.widget.TextView.<init>(TextView.java:700)
at com.android.layoutlib.bridge.MockView.<init>(MockView.java:50)
at com.android.layoutlib.bridge.MockView.<init>(MockView.java:45)
at com.android.layoutlib.bridge.MockView.<init>(MockView.java:41)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:163)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:95)
at com.android.layoutlib.bridge.bars.StatusBar.<init>(StatusBar.java:67)
at com.android.layoutlib.bridge.impl.Layout.createStatusBar(Layout.java:222)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:144)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:297)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:520)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:508)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:75)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:620)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:654)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:596)
at …
Run Code Online (Sandbox Code Playgroud)

android android-studio-2.1

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

Xamarin Forms的Toast等效物

是否有任何方法使用Xamarin Forms(不是Android或iOS特定的)来弹出,就像Android与Toast一样,不需要用户交互,并在一段(短)时间后消失?

从搜索所有我看到的是需要用户点击消失的警报.

c# toast xamarin xamarin.forms

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

未调用基于单元测试的类中的ClassInitialize属性

我在TestBase类中添加了这些方法:

[ClassInitialize]
public static void InitializBeforeAllTests()
{
}
Run Code Online (Sandbox Code Playgroud)

但是当我在Debug中运行一个单元测试Test1():

[TestClass]
public class TestMapping : TestBase
{
    [TestMethod]
    public void Test1()
    {
    }
Run Code Online (Sandbox Code Playgroud)

TestBase.InitializBeforeAllTests()永远不会调用该方法.为什么?

c# vs-unit-testing-framework

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

MSTEST中的DataTestMethod和DataRow属性

我在Microsoft视频中看到有关这些属性的Visual Studio更新2.但是,我找不到关于它们的任何其他信息,也无法使用它们构建项目.

有没有人知道这些属性或如何让它们工作?

[DataTestMethod]
[DataRow("a", "b")]
[DataRow(" ", "a")]
public void TestMethod1(string value1, string value2)
{
    Assert.AreEqual(value1 + value2, string.Concat(value1, value2));
}
Run Code Online (Sandbox Code Playgroud)

c# unit-testing mstest

39
推荐指数
3
解决办法
3万
查看次数

禁用布局中的所有子视图

在发布我的问题之前,我看到了许多与此相关的线程.但没有一个对我有用.我有一个RelativeLayout与许多其他布局和片段作为孩子.我想在单击按钮时禁用"content_view"的所有子项以及content_view本身.我试过了

contentView.setDisabled(false);
Run Code Online (Sandbox Code Playgroud)

这没用.我也试过了

for (int i = 0; i < layout.getChildCount(); i++) {
    View child = layout.getChildAt(i);
    child.setEnabled(false);
}
Run Code Online (Sandbox Code Playgroud)

即使这样也行不通.我究竟做错了什么?请在下面找到我的.xml代码.我甚至尝试在所有视图上方放置一个视图.即使这并没有解决我的问题.

<RelativeLayout
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:id="@+id/content_view"
    android:background="#ffffff">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/channel_actionbar"
        android:layout_marginLeft="0dp"
        android:layout_marginTop="0dp"
        android:duplicateParentState="true">

        <FrameLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:id="@+id/body_container"
            android:layout_below="@+id/channel_actionbar"
            android:duplicateParentState="true">

            <RelativeLayout
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:id="@+id/channelList"
                android:duplicateParentState="true">

                <com.mobile.subview.ScrollViewWithScrollListener
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/scrollView"
                    android:layout_alignParentTop="false"
                    android:duplicateParentState="true">

                    <RelativeLayout
                        android:orientation="vertical"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:duplicateParentState="true">

                        <FrameLayout
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:id="@+id/imagePlaceHolder"
                            android:duplicateParentState="true"></FrameLayout>

                        <TableLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:id="@+id/channelTable"
                            android:layout_below="@+id/imagePlaceHolder"
                            android:duplicateParentState="true"></TableLayout>

                        <com.mobile.subview.CustomTextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="You do not qualify for any engagements or channels.  Please …
Run Code Online (Sandbox Code Playgroud)

java android childviews

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

应用程序在后台时的GeoFence设备

我已经实现了geoFence api,一切都运行良好.但是有一些问题,我想对我的困惑做更多的澄清.

以下是一些混淆和问题:

  1. 我希望我的用户在进入地理围栏区域时收到通知.我按照指南实现了GeofenceTransitionsIntentService,但是当应用程序处于后台时它不会触发转换.我该怎么办?

  2. GeoFence过期时间:很明显,如果我们进入Never,它不会过期,但我对时间感到困惑.例如,如果我将其设置为10分钟,那究竟是做什么的?地理围栏是否会在创建后的给定时间后到期,或者当用户到达该位置时会到期,然后计时器将启动?当用户到达那里时,我们如何让地理围栏过期.

  3. Google如何跟踪我们?地理围栏实际上如何运作?我们没有发送我们的位置,那么它现在正在跟踪?当我们添加地理围栏然后在到达那个地方时通知我们,它是否开始跟踪我们?

请告诉我并讨论这些混淆,特别是关于它在应用程序关闭或销毁时工作的困惑.

android android-geofence google-geolocation

7
推荐指数
1
解决办法
2029
查看次数

Android多行工具栏标题

我有一个工具栏,当在横向模式下不像平常那​​样宽,但它有比平常更高的高度,因此我想在横向时将标题设置为多线(准确地说是2行).我尝试了一些将TextView放在工具栏中的东西,但是当我尝试访问TextView来设置它的标题时(因为标题是可变的)我在使用findViewById后得到一个NullPointer.

以下是当前情况的一些代码(没有多行):

@Override
protected void onResume() {
    super.onResume();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar2);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = (int)( size.x * 0.37);
        int height =  Math.round(size.x * 0.63f * 0.25f);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width,height);
        toolbar.setLayoutParams(params);
    }
    if (executeOnResume) {
        currentProject = getIntent().getParcelableExtra("Project");
        getSupportActionBar().setTitle("This is a pretty long piece of text, I hope it fits");
        // A lot of irrelevant code...
        //...
        //...
    } else …
Run Code Online (Sandbox Code Playgroud)

java android android-toolbar

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

Alamofire请求参数为空

我正在尝试使用Alarmofire库发送POST请求,但请求不会正确发送参数.

我的代码:

let parameters : Parameters = [
    "email": tfLoginEmail.text! as String,
    "password": tfLoginPassword.text! as String
]
Alamofire.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseJSON{ response in
    //Some code that uses the response
}
Run Code Online (Sandbox Code Playgroud)

参数变量的计数为2且两个值都存在,但对此请求的响应是关于电子邮件和/或密码为空的错误.

编辑: 我的PHP:

/**
 * Account Login
 * url - /login
 * method - POST
 * params - email, password
 */
$app->post('/login', function() use ($app) {
            // check for required params
            verifyRequiredParams(array('email', 'password'));

            // reading post params
            $email = $app->request()->post('email');
            $password = $app->request()->post('password');
            $response = array();

            $db …
Run Code Online (Sandbox Code Playgroud)

php swift alamofire

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

Xamarin 窗体框架阴影设计

我有一个带有列表的 Xamarin 内容页面。对于 ListItems,我想要类似于 Android 中的 cardview 的东西。

在此处输入图片说明

基于我发现可以通过框架完成的内容。我有这个代码:

<ViewCell>
    <StackLayout Padding="8" >
        <controls:CardView HasShadow="True" OutlineColor="LightGray">
            <StackLayout Orientation="Vertical" Padding="5">
                // Some labels and Buttons                
            </StackLayout>
        </Frame>
    </StackLayout>
</ViewCell>
Run Code Online (Sandbox Code Playgroud)

CardView 具有以下代码:

public class CardView : Frame
{
    public CardView()
    {
        Padding = 0;
        if (Device.RuntimePlatform == Device.iOS)
        {
            HasShadow = false;
            OutlineColor = Color.Transparent;
            BackgroundColor = Color.Transparent;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这会导致类似这样的事情:

在此处输入图片说明

这看起来更像是一个边框,而不是这张卡片悬浮效果。上面的示例实际上使用了相同的 cardview 控件,没有任何样式(即使没有 OutlineColor)。我是否错过了必须配置的选项?或者我怎样才能达到与样本相同的结果?

Xamarin.Forms 版本:2.5.0.280555

c# xaml xamarin.forms

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

Android:setBackgroundColor 而不删除我的 drawable

我有一个按钮:

<Button
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    android:text="@string/male"
    android:id="@+id/btn_mgen_m"
    android:layout_gravity="center_horizontal"
    android:background="@drawable/bg_tgl_btn_left"
    android:textColor="#444444" />
Run Code Online (Sandbox Code Playgroud)

我像这样改变了它的颜色:

btnMgenM = (Button) findViewById(R.id.btn_mgen_m);
btnMgenM.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        btnMgenM.setBackgroundColor(Color.parseColor("#dca8c3"));
    }
});
Run Code Online (Sandbox Code Playgroud)

背景颜色已正确更改,但似乎删除了可绘制的背景。圆半径、文本颜色和边框被删除,只留下简单的彩色按钮。我想在单击此按钮时更改背景颜色,但不更改其他任何内容。

我怎样才能做到这一点?

xml android drawable

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