如果我对导航抽屉做任何事情,我会收到此错误。
Motion event has invalid pointer count 0; value must be between 1 and 16.
此错误不会导致我的活动崩溃。但只是充斥着我的日志。以下是活动。适配器是自定义适配器,其中包含图像和文本。
public class FirstActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
private DrawerLayout drawerLayout;
private ActionBarDrawerToggle actionBarDrawerToggle;
private ListView navList;
private NavAdapter navAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
drawerLayout = (DrawerLayout)findViewById(R.id.drawerLayout);
navList = (ListView)findViewById(R.id.navigation_list);
navAdapter = new NavAdapter(this);
navList.setAdapter(navAdapter);
navList.setOnItemClickListener(this);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.opendrawer, R.string.closedrawer);
drawerLayout.setDrawerListener(actionBarDrawerToggle);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(actionBarDrawerToggle.onOptionsItemSelected(item)){
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
actionBarDrawerToggle.onConfigurationChanged(newConfig);
}
@Override
public void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
actionBarDrawerToggle.syncState();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
navList.setItemChecked(position, true);
String menuItem = (((TextView)view.findViewById(R.id.drawerTV)).getText().toString());
getSupportActionBar().setTitle(menuItem);
}
}