gpt4 book ai didi

java - 在 arrayadapter 中交换数据时从 Binder stub 实现中捕获 RuntimeException

转载 作者:行者123 更新时间:2023-12-01 06:56:48 25 4
gpt4 key购买 nike

public class MainActivity extends AppCompatActivity {

ArrayList<String> list = new ArrayList<>();

ArrayAdapter<String> adapter;

ArrayList<String> data1 = new ArrayList<>();

ArrayList<String> data2 = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

for (int i = 0 ; i< 10 ;i++){
data1.add(String.valueOf(i));
}

for (int i = 20; i < 30; i++){
data2.add(String.valueOf(i));
}

Spinner spinner = (Spinner) findViewById(R.id.demo);
adapter = new ArrayAdapter<>(this,android.R.layout.simple_dropdown_item_1line,list);
spinner.setAdapter(adapter);
}

private void change(boolean which){
if (which){
list.clear();
list.addAll(data1);

}else{
list.clear();
list.addAll(data2);

}
adapter.notifyDataSetChanged();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_no) {
change(true);
return true;
}else if (id == R.id.action_ok){
change(false);
return true;
}

return super.onOptionsItemSelected(item);
}
}

当我在微调器中交换数据时,出现错误:
08-25 11:51:59.630   29087-9866/me.aber.app.arrayapdapterdemo
D/dalvikvm? GC_FOR_ALLOC freed 2055K, 52% free 7378K/15192K, paused 24ms, total 30ms
08-25 11:52:01.923 29087-9866/me.aber.app.arrayapdapterdemo
W/Binder? Caught a RuntimeException from the binder stub implementation.
java.lang.NullPointerException
at android.view.WindowManagerGlobal.dumpGfxInfo(WindowManagerGlobal.java:437)
at android.app.ActivityThread$ApplicationThread.dumpGfxInfo(ActivityThread.java:1021)
at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:550)
at android.os.Binder.execTransact(Binder.java:404)
at dalvik.system.NativeStart.run(Native Method)

当我单击该操作时,它会随机出现。

最佳答案

W/Binder? Caught a RuntimeException from the binder stub implementation.
java.lang.NullPointerException

消息以 W/ 开头,这意味着它只是一个警告。所以你可以忽略它。它的Android内部可以忽略的问题。

这可能是警告的来源: https://android.googlesource.com/platform/frameworks/base.git/+/master/core/java/android/os/Binder.java#1054

如果您的代码正常工作,那么您应该忽略这些警告。

关于java - 在 arrayadapter 中交换数据时从 Binder stub 实现中捕获 RuntimeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32195304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com