无法对ListView执行onClick操作

时间:2012-10-25 10:36:14

标签: java android listview onclick

这是我的代码。按下项目时,我收到强制关闭错误。坚持这个计划。找不到合适的解决方案

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);       
    }
});

1 个答案:

答案 0 :(得分:0)

在您的清单文件中添加ComponentInfo,如下所示

<activity android:name="ComponentInfo" android:screenOrientation="portrait"
                    android:configChanges="orientation"></activity>

我想这会对你有所帮助......