कैसे बनाने के लिए और आसान बनाने के लिए जावा कोड Android

0

सवाल

मैं कैसे कर सकते हैं आसान बनाने में सभी इस कोड? मैं निर्माण कर रहा हूँ एक खोज मेनू पर जाएँ और मैं चाहते हैं के लिए मूल्यों की जाँच जब उपयोगकर्ता से बाहर निकालता है एक 'पाठ देखें' और आउटपुट प्रदर्शित के रूप में तुरंत एक 'रीसायकल दर्शक' नीचे.

  • एक तरीका है ऐसा करने के लिए, के साथ एक बहुत बड़ी संख्या के आईएफएस. क्या आप सुझाव है कि एक अन्य विधि?

  • मैं का उपयोग करें Roon पुस्तकालय के लिए अपने आवेदन के एक डेटाबेस है ।

मैं चाहता था करने के लिए इस कोड का उपयोग इस के लिए लेकिन मैंने देखा है कि संख्या के आईएफएस बहुत अधिक है ।

  • एक दोस्त का सुझाव दिया उपयोग के मामले में डेटाबेस है, लेकिन मैं नहीं जानता कि कैसे लिखने के लिए अपने कोड!

         public void searchHelper() {
         String sOperationValue = spinnerOperation.getText().toString();
         String sTraderValue = spinnerTraderName.getText().toString();
         String sSearchByValue = spinnerSearchBy.getText().toString();
         long startValue = Long.parseLong(etStartDate.getText().toString());
         long endValue = Long.parseLong(etEndDate.getText().toString());
    
         // * * * * *
         if (!sOperationValue.isEmpty() &&
                 !sTraderValue.isEmpty() &&
                 !sSearchByValue.isEmpty() &&
                 startValue >= 14000000 &&
                 endValue <= 15000000) {
    
         }
         // * - * * *
         if (!sOperationValue.isEmpty() &&
                 sTraderValue.isEmpty() &&
                 !sSearchByValue.isEmpty() &&
                 startValue >= 14000000 &&
                 endValue <= 15000000) {
    
         }
         // * - - - -
         if (!sOperationValue.isEmpty() &&
                 sTraderValue.isEmpty() &&
                 sSearchByValue.isEmpty() &&
                 startValue <= 0 &&
                 endValue <= 0) {
    
         }
         // - * * * *
         if (sOperationValue.isEmpty() &&
                 !sTraderValue.isEmpty() &&
                 !sSearchByValue.isEmpty() &&
                 startValue >= 14000000 &&
                 endValue <= 15000000) {
    
         }
         // Here 'Search By' specifies whether the search should be based on the date of registration or on the date of the transaction.
         // Therefore, when Search By is empty, then the start date and end date values are also empty.
         // - * - - -
         if (sOperationValue.isEmpty() &&
                 !sTraderValue.isEmpty() &&
                 sSearchByValue.isEmpty() &&
                 startValue <= 0 &&
                 endValue <= 0) {
    
         }
         // - - * * *
         if (sOperationValue.isEmpty() &&
                 sTraderValue.isEmpty() &&
                 !sSearchByValue.isEmpty() &&
                 startValue >= 14000000 &&
                 endValue <= 15000000) {
    
         }
         // - - - - -
         if (sOperationValue.isEmpty() &&
                 sTraderValue.isEmpty() &&
                 sSearchByValue.isEmpty() &&
                 startValue <= 0 &&
                 endValue <= 0) {
    
         }
     }
    
  • मैं भी चाहता था लिखने के लिए एक क्वेरी का उपयोग कर के मामले में, लेकिन असफल रहा । यह था के मैं ने लिखा कोड

     @Query("SELECT * FROM tbl_transaction" +
         " WHERE CASE WHEN operation='null'" +
         " THEN CASE WHEN traderName='null'" +
         " THEN CASE WHEN transactionType ='null'" +
         " THEN CASE WHEN startDate=14000000" +
         " THEN CASE WHEN endDate=15000000" )
         List<Transaction> getSearchValues(String operation, String traderName, String transactionType, long startDate, long endDate);
    

हालांकि मैं बहुत था के लिए देख रहे हैं सही समाधान है, दुर्भाग्य से मैं नहीं मिल सकता है.

धन्यवाद आपकी मदद के लिए अग्रिम.

Form Image

android android-room database java
2021-11-23 22:09:06
2
0

OperationType, TraderName, SearchBy सभी तरह दिखेगा स्पिनरों. कर रहे हैं, जहां आप हो रही डेटा पॉप्युलेट करने के लिए विकल्प. अगर इसकी hardcoded अनुप्रयोग में कैसे पर निर्भर करता है आप को लागू करने, इसकी संभावना नहीं है वे जाएगा, कभी खाली है, क्योंकि वहाँ हमेशा एक डिफ़ॉल्ट विकल्प चयनित है । आप की जरूरत नहीं हो सकती अगर जाँच करने के लिए वे खाली कर रहे हैं । तो आप ज्यादातर पर ध्यान केंद्रित किया जाएगा startDate बताता Edittexts. आप तब आगे सुधार का उपयोग करके तारीख बीनने वालों के बजाय.

2021-11-24 00:13:17
0

मैं छोटा यह आप के लिए नहीं है, यह सबसे अच्छा तरीका है यह करने के लिए लेकिन यह अभी भी काम करता है

मैं का एक छोटा संस्करण है, लेकिन यह कुछ समय ले जाएगा के बाद से यह और अधिक जटिल हो जाएगा बनाने के लिए:

public void searchHelper() {
    boolean b1 = spinnerOperation.getText().toString()isEmpty();
    boolean b2 = spinnerTraderName.getText().toString()isEmpty();
    boolean b3 = spinnerSearchBy.getText().toString()isEmpty();
    boolean b4 = Long.parseLong(etStartDate.getText().toString()) >= 14000000 && Long.parseLong(etEndDate.getText().toString()) <= 15000000;
     boolean b5 = Long.parseLong(etStartDate.getText().toString()) <= 0 && Long.parseLong(etEndDate.getText().toString()) <= 0;

     // * * * * *
     if (!b1 && !b2 && !b3 && b4) {

     }
     // * - * * *
     if (!b1 && b2 && !b3 && b4) {

     }
     // * - - - -
     if (!b1 && b2 && b3 && b5) {

     }
     // - * * * *
     if (b1 && !b2 && !b3 && b4) {

     }
     // Here 'Search By' specifies whether the search should be based on the date of registration or on the date of the transaction.
     // Therefore, when Search By is empty, then the start date and end date values are also empty.
     // - * - - -
     if (b1 && !b2 && b3 && b5) {

     }
     // - - * * *
     if (b1 && b2 && !b3 && b4) {

     }
  // - - - - -
    if (b1 && b2 && b3 && b5) {

  }
 }
2021-11-24 00:02:54

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

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

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