簡體   English   中英

無法在ListView上執行onClick操作

[英]Unable to perform onClick action on a ListView

這是我的代碼。 按項目時出現強制關閉錯誤。 卡在這個程序中。 沒有找到正確的解決方案

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

像這樣在清單文件中添加ComponentInfo

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

我想這會幫你...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM