这是我的代码。当按下 item 时,我收到强制关闭错误。卡在这个程序里了。没有找到合适的解决方案
myList = (ListView)findViewById(R.id.myList);
Adapter = new MobileArrayAdapter(FileShare.this, MOBILE_OS);
myList.setAdapter(Adapter);
myList.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
// Toast.makeText(getApplicationContext(), "Your message here", Toast.LENGTH_SHORT).show();
Intent i = new Intent(FileShare.this, sharedView.class);
Intent pickFileIntent = new Intent();
pickFileIntent.setAction(Intent.ACTION_GET_CONTENT);
pickFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
pickFileIntent.setType("*/*");
Intent chooserIntent = Intent.createChooser(pickFileIntent, getText(R.string.choosefile_title));
startActivityForResult(chooserIntent, PICK_FILE_REQUEST);
startActivity(i);
}
});
最佳答案
在 list 文件中添加ComponentInfo
,如下所示
<activity android:name="ComponentInfo" android:screenOrientation="portrait"
android:configChanges="orientation"></activity>
我想这会对你有帮助......
关于java - 无法在 ListView 上执行 onClick 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13066727/