Gson反序列化JSON。 java.lang.RuntimeException:无法调用具有根本原因的public com.derp.procedure.model.SkeletonElement(),无参数)

这是我第一次与JSON和Java。 我已经检查了很多像我一样的错误的问题。 但没有发现任何有用的东西。 我明白,我不得不添加参数构造函数。 我已经修好了,但它没有帮助我。 仍然发生相同的错误。 它可以这样工作。 我认为这与我的代码相当复杂的inheritance有关。 错误: SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/derp] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: Failed to invoke public com.derp.procedure.model.SkeletonElement() with no args] with root cause java.lang.InstantiationException 堆栈跟踪: gru 19, 2014 8:27:50 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [dispatcher] in context […]

状态栏是隐藏的,但色调仍然可见

我有一个Android应用程序,它具有播放video的活动。 虽然通常我的应用程序中的某些活动具有动态状态栏颜色,但是当video活动处于横向状态时,我隐藏了状态栏。 但即使我全屏隐藏状态栏,状态栏的色调仍然存在。 请告诉我如何隐藏状态栏的色调。 用于设置状态栏颜色的代码 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SystemBarTintManager tintManager = new SystemBarTintManager(((Activity) context)); tintManager.setStatusBarTintEnabled(true); tintManager.setNavigationBarTintEnabled(false); tintManager.setTintColor(Color.parseColor(“#” + dynamicColor)); float f = Float.parseFloat(“.7”); tintManager.setTintAlpha(f); } 我用于删除状态栏颜色的代码 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(false); tintManager.setNavigationBarTintEnabled(false); float f = Float.parseFloat(“0”); tintManager.setTintAlpha(f); getWindow().setStatusBarColor(Color.TRANSPARENT); } 现在在tint消除代码中,我将setStatusBarEnabled标志setStatusBarEnabled为false 。 即使setStatusBarColor是TRANSPARENT 。 任何帮助将不胜感激。

BitmapFactory返回null位图

我试图从StaticConfig.getMyUser().getAvatar()的URL中获取位图。 url如下: “android/photo.jpg” 。 当我使用下面的代码时, src为空。 我不知道为什么。 我目前正在研究这个链接,但我仍然无能为力。 private void setImageAvatar(Context context){ Resources res = getResources(); Bitmap src; byte[] decodedString = Base64.decode(StaticConfig.getMyUser().getAvatar(), Base64.DEFAULT); src = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); if(src == null){ Log.e(“UserProf”,”src is null”); } // code to do something with src here }

TimePickerDialog取消按钮

我有一个活动 – TimePickerActivity – 它创建一个TimePickerDialog。 我有一个onTimeSetListener响应设置按钮在它结束时调用finish()并返回到调用TimePickerActivity的活动。 我希望它完成并返回,如果取消按钮被点击,但无法find任何方式来做到这一点。 我GOOGLE了一遍,尝试了整体的建议,但没有一个似乎工作。 任何简单的方法来做到这一点?

kotlin库模块中调试目录的未解决的参考

我第一次使用Kotlin开发Android应用程序。 目前我正在使用我的项目中的一个库模块(“数据”),与主应用程序模块分开: > [Root directory] > app > […] > data > src > debug > kotlin > com.domain.app > […] > main > kotlin > com.domain.app > […] > release > kotlin > com.domain.app > […] 我遇到了一个障碍:每当data.src.main内的文件引用data.src.debug中的文件时,构建过程将失败,并显示消息“Unresolved reference:[class name]”。 但是,当我在data.src.release中引用文件时,它不会失败。 在这两种情况下,我已经三重检查了语法,目录和构建变体。 我没有修改我的build.gradle文件中的调试版本或发布版本 – 我使用的是默认设置。 我的源文件是: android { … sourceSets { main.java.srcDirs += ‘src/main/kotlin’ debug.java.srcDirs […]

如何捕捉RecyclerView项目,以便每个X项目将被视为一个单元来捕捉?

背景 可以使用以下方法将RecyclerView锁定到其中心: LinearSnapHelper().attachToRecyclerView(recyclerView) 例: MainActivity.kt class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val inflater = LayoutInflater.from(this) recyclerView.adapter = object : RecyclerView.Adapter() { override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { val textView = holder.itemView as TextView textView.setBackgroundColor(if (position % 2 == 0) 0xffff0000.toInt() else 0xff00ff00.toInt()) textView.text = position.toString() } override fun […]

无法通过Springboot连接到远程MongoDB

我试图连接到一个远程的MongoDB。 由于我没有得到一个MongoOpenSocketException,我认为已经建立了一个连接,但需要更多的启动应用程序。 我错过了什么? Application.kt package hello import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration import org.springframework.context.annotation.Configuration /** * The main entry point to the application */ @EnableAutoConfiguration(exclude = arrayOf(MongoAutoConfiguration::class)) @Configuration class Application /** * Run the application * @param args The command line arguments */ fun main(args: Array) { SpringApplication.run(Application::class.java, *args) } 的build.gradle: // Top-level build file […]

在Kotlin中调用Java静态方法的可能性

假设我们有一个Java静态方法: //Java code public static void printFoo() { System.out.println(“foo”); } 在Kotlin中可以调用这个方法吗?

代码审查最好的方法使用SharedPreferences解决MemoryLeak

我尝试解决共享偏好使用中的内存泄漏,我整天尝试这样做,但仍然混淆,我的目标是可能调用pref在任何我想要的。 在这里我的代码。 class Preferences (private val context: Context) { private val sharedPreferences: SharedPreferences = context.getSharedPreferences(context.packageName+”_pref”, Context.MODE_PRIVATE) private val editor: SharedPreferences.Editor companion object { private val KEY_USER = “user” private val KEY_EMAIL = “email” } init { editor = sharedPreferences.edit() } private fun isKeyExist(Key: String): Boolean = sharedPreferences.contains(Key) private fun putString(Key: String, value: String) { editor.putString(Key, […]

ImageButton OnClickListener不工作

所以我有一个片段中的以下ImageButton: 和下面的片段Activity.txt class Home : Fragment() { override public fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view: View? = inflater.inflate(R.layout.fragment_home, container, false) val moneyButton: ImageButton = view?.findViewById(R.id.moneyBtn) as ImageButton val result = MyAppApplication() var money = result.money moneyButton.setOnClickListener(View.OnClickListener { Toast.makeText(activity, “TESTING BUTTON CLICK 1”, Toast.LENGTH_SHORT).show() }) return view } 我也尝试使用“正常”Kotline setOnClickListener moneyButton.setOnClickListener […]