没有向HAL提供足够的数据,预期位置 [英] Not supplying enough data to HAL, expected position

查看:775
本文介绍了没有向HAL提供足够的数据,预期位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android Studio中遇到此错误.我只想在按下按钮时打印文本.我收到以下错误,每次按此按钮时都会出现.如果我取消注释的意图,它也可以很好地工作,但是我拥有的代码越多,错误更改就越多.我实际上不确定这是否是真正的错误.我之所以这样说,是因为我有一个完整的应用程序(不是此应用程序),该应用程序使用翻新和github api搜索存储库.此按钮是搜索的纽带.如果我用一个词硬编码,该应用程序将完美运行.我终于找到了这个简化的应用程序,试图找到根本原因.请帮忙.

I'm getting this error in Android Studio. I just want to print the text when I push the button. I get the below error, which appears every time I press the button. If I uncomment out the intent it works perfectly fine as well, but the more code I have the more the error changes. I am not actually sure this is the true error. I say this because I have an entire app (not this one) that uses retrofit and github api to search for repos. This button is the nexus for searching. If I hard code in a word the app works perfectly. I finally got to this simplified app in an attempt to find the root cause. Please help.

1.

10-17 15:33:56.569 1404-1431/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 2045606 , only wrote 1793520

  1. 这是代码

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText


class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val editText = findViewById<EditText>(R.id.searchEditText)
        val searchEditText = editText.text.toString()


        val button = findViewById<Button>(R.id.searchButton)
        button.setOnClickListener {
            println(searchEditText)
            //val intent = Intent(this,SearchResultActivity::class.java)
            //intent.putExtra("searchTerm",searchEditText)
            //startActivity(intent)
        }
    }
}

  1. 这是清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.blah.test236">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".SearchResultActivity" />
</application>

  1. 这是xml文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.dnarialpressley.test236.MainActivity"
    tools:ignore="DuplicateIds">
<EditText
    android:id="@+id/searchEditText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dp"
    android:ems="10"
    android:inputType="textPersonName"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<Button
    android:id="@+id/searchButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:text="@string/button"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/searchEditText" />
</android.support.constraint.ConstraintLayout>

推荐答案

XML很好,但是主要活动类未正确使用kotlin,为了从布局中绑定项目,您可以使用 synthetic 这样的本地库

XML are fine but the main activity class is not using kotlin in the right way, in order to bind your items from your layout you can use synthetic native library like this

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.* // this imports all your items from your layout

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val searchEditText = searchEditText.text.toString() 
        // you can now use any items in the layout just by calling them

        searchButton.setOnClickListener{
            println(searchEditText)
        }

    }
}

希望有帮助

这篇关于没有向HAL提供足够的数据,预期位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆