小编jer*_*ron的帖子

Android资源$ NotFoundException来自旧手机的可绘制资源API 18

我只是在使用Android 4.3和API 18的三星Galaxy Nexus手机上进行测试时遇到以下错误.

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_error.xml
 from drawable resource ID #0x7f020098
    at android.content.res.Resources.loadDrawable(Resources.java:2091)
    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
    at android.widget.TextView.<init>(TextView.java:803)
    at android.widget.EditText.<init>(EditText.java:60)
Run Code Online (Sandbox Code Playgroud)

在我的Acitivty.java文件中,我尝试使用以下方法设置我的矢量drawable:

editTextNickname.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_error, 0);
editTextNickname.setCompoundDrawables(null, null,
    ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_error), null);
Run Code Online (Sandbox Code Playgroud)

我在build.gradle文件中使用了最新的支持库,如下所示:

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'

android {
  compileSdkVersion 24
  buildToolsVersion "23.0.3"

defaultConfig {
  applicationId "com.peprally.jeremy.peprally"
  minSdkVersion 16
  targetSdkVersion 24
  versionCode 1
  versionName "1.0"
  vectorDrawables.useSupportLibrary = true
}
buildTypes {
  release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
  debug {
    debuggable true
  }
}

repositories {
  mavenCentral() …
Run Code Online (Sandbox Code Playgroud)

java android gradle android-support-library

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

声明变量vs动态地将内存分配给c ++中的变量?

我只是在声明一个变量之间的区别时有点困惑,例如:

int n;
Run Code Online (Sandbox Code Playgroud)

并使用"new"动态地将内存分配给变量,例如:

int m = new int;
Run Code Online (Sandbox Code Playgroud)

我注意到只是在处理一个简单的链表项目时,当我以节点对象的形式插入一个新值时,我必须动态创建一个新的节点对象并将所需的值附加到它,然后将其链接到我列表的其余部分.但是..在同一个函数中,我可以定义另一个节点对象,例如.NodeType*N. 并使用此指针遍历我的列表.我的问题是..当我们只是声明一个变量时,内存是不是立刻被分配了......或者有什么区别?

谢谢!

c++ variables

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

使用什么样的数据结构?

我正在开展一个需要跟踪的项目:

  • 5-6只是字符串名称的根项
  • 每个根项都需要具有不同标识符类型的多个子项(int,string,float等).一个根的所有子节点都是相同类型,但每个根节点将具有不同的子类型
  • 用户需要能够从每个根添加/删除子项
  • 我稍后需要单独访问每个孩子,并在需要时执行字符串操作和解析

我想过可能会使用一个字典,其中Key是一个字符串,而Values是对象列表.或者为每个根项创建一个唯一的类,每个类将包含一个子列表.

有没有人有任何好的建议?我对OOP还很新,请耐心等我:)

谢谢!

c# oop data-structures

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