कैसे कर सकते हैं मैं एक FileChooser आबाद करने के लिए एक TextView के दौरान एक TableRow निर्माण?

0

सवाल

समस्या: मैं कर रहा हूँ परेशानी हो रही है एक FileChooser वर्ग आबाद करने के लिए एक TextView के दौरान एक TableRow निर्माण. मैं प्राप्त एक Invocation Exception एंड्रॉयड में बनाया "looper.java" प्रकट होता है, जो कारण हो करने के लिए एक चर tagTrace=0 पढ़ा जा रहा है के रूप में "!=0". तो, मैं नहीं हूँ यकीन है कि कैसे मैं में सक्षम हो सकता है वैकल्पिक हल के लिए यह.

क्या मैं कोशिश कर रहा हूँ करने के लिए करते हैं: मैं कोशिश कर रहा हूँ का निर्माण करने के लिए पर करने के लिए एक मौजूदा प्रक्रिया. जब एक उपयोगकर्ता पर क्लिक करने पर एक "+" बटन पर हेडर पंक्ति के एक TableLayout, यह बनाता है के साथ एक पंक्ति में दो दर्शनों की संख्या: एक "हटाएँ" (-) Button पंक्ति में.बच्चे(0) और एक TextView पंक्ति में.बच्चे(1). यह इस करता है सफलतापूर्वक किया है. वहाँ है एक Singleton वर्ग का प्रबंधन करता है कि विभिन्न प्रकार के TableRow कृतियों के लिए सभी एप्लिकेशन Actiities.

पर एक विशेष Activity मौजूद फ़ाइलों की एक TableLayout. मैं करना चाहते हैं जब उपयोगकर्ता क्लिक करने पर "+" buttion मैं ऊपर वर्णित है, एक शुरू करने के लिए FileChooser पर कब्जा करने के लिए एक फ़ाइल पथ और आबाद है कि करने के लिए पथ TextView बच्चे की यह पंक्ति पैदा कर रही है. हालांकि, मैं चल रहा हूँ में इस मुद्दे के ऊपर.

के Looper.java बग (मुझे लगता है) के कारण मंगलाचरण अपवाद

Looper Bug

के FileChooser

    public class FileChooser extends AppCompatActivity {
        private String fileName;
        private String filePath;
        private final ActivityResultLauncher<Intent> resultLauncher;
    
        public FileChooser(){
            //if(intent==null) Toast.makeText(null, "Intent is Null", Toast.LENGTH_SHORT).show();
            this.resultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null){
                    Uri uri = result.getData().getData();
                    filePath = uri.getPath();
                }
            });
        }
    
        public String getFileName() {
            return fileName;
        }
    
        public String getFilePath() {
            return filePath;
        }
    
        public ActivityResultLauncher<Intent> getResultLauncher() {
            return resultLauncher;
        }

}

विधि के भीतर सिंगलटन बनाने TableRow के "!बोल्ड"

public static TableRow setupFilesTableRow(Context context, TableLayout table, String fileID, String fileName, boolean bold) {
    TableRow row = new TableRow(context);
    if(bold) {
        row.addView(setupFilesAddRowButton(context, table));
        row.addView(addRowTextViewToTable(context, fileName, true));
    }
    if (!bold) {
        row.addView(setupDeleteRowButton(context, table));
        
            // Intent and FileChooser to capture a filePath
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("*/*");
            FileChooser fileChooser = new FileChooser();
            fileChooser.getResultLauncher().launch(intent);

            // Adding a TextView child to the new TableRow with the captured filePath from the FileChooser
            row.addView(addRowTextViewToTable(context, fileChooser.getFilePath(), false));
            //row.setClickable(true);
        
    }
    return row;
}
android filechooser java tablerow
2021-10-21 13:18:53
1
1

FileChooser fileChooser = नया FileChooser();

आप नहीं कर सकते बनाने के लिए एक नई गतिविधि के साथ new ऑपरेटर.

गतिविधियों है करने के लिए शुरू किया जा सकता का उपयोग कर एक मंशा.

2021-10-21 13:38:09

मैं देख रहा हूँ, मैं नहीं लगता था कि जाहिर है, कि समझ बनाने के लिए ।
svstackoverflow

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................