Domanda

question changed :

in my app i need that check a string value with all value of a string array;

i used this Code that check value from i=0 to i=4;

public void onCreate(Bundle savedInstanceState)
{
      ...
 ArrayList<String> ch= new ArrayList<String>();
    ch.add("س");
    ch.add("ل");
    ch.add("ا");
    ch.add("م");
      ...
 } 

but this loop just return last i value-(i=4) and don't add i value additive.

  private final TextWatcher TextWatcher_Method = new TextWatcher() 
    {   
     public void onTextChanged(CharSequence arg0, int start, int befor, int count) 
        {

          String matn = "Edit-Text String";
          int fa_cnt=0;

        for (int i=0;i<4;i++)
          {
           if(matn.contains(ch.get(i)))
            {
                fa_cnt=4;
            } 
            else
            {
                fa_cnt=8;
            }
          } 

        }
     }

but this Loop , in Outside of the TextWatcher do right.

È stato utile?

Soluzione 5

OK i solve this question with below Codes :

at first i declare a array like this :

CharSequence it[]={"آ","ا","ب","پ","ت","ث","ج","چ","ح","خ","د","ذ",
        "ر","ز","ژ","س","ش","ص","ض","ط","ظ","ع","غ","ف","ق"
        ,"ک","گ","ل","م","ن","و","ه","ی","ء"};

Then in TextWatcher wrote below codes :

     private final TextWatcher TextWatcher_Method = new TextWatcher() 
         {  
            public void onTextChanged(CharSequence arg0, int start, int  befor,int count) {}

            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {}

            public void afterTextChanged(Editable arg0)
              {
                fa_cnt=8;
                TextView counter=(TextView)findViewById(R.id.txt_counter);
                String matn =matn_counter.getText().toString();

               for (int i=0;i<it.length;i++)
                {
                    if(matn.contains(it[i]))
                    {
                        fa_cnt=4;
                    }
                }
            cnt2=matn_counter.length();
            cnt1=(int) Math.ceil(cnt2/fa_cnt);
            Integer cnt3=(cnt2%fa_cnt);

            counter.setText(Integer.toString(cnt1)+"/"+Integer.toString(cnt3));

            }
       } 

This Codes , detect that in a edit-text , contains Persian(Parsi-Farsi-Iran) alphabet or no!

Altri suggerimenti

Have you added internet permissions in manifest file?

Have you provided the INTERNET permission in your manifest file ?

   <uses-permission android:name="android.permission.INTERNET" />

@saeid add webview to main.xml and Update AndroidManiferst.xml with internet permission

<uses-permission android:name="android.permission.INTERNET" />

//add this between loadurl and browser=

    browser.getSettings().setJavaScriptEnabled(true);

See what says Android docs at handling page navigation

If you want more control over where a clicked link load, create your own WebViewClient that overrides the shouldOverrideUrlLoading() method. For example:

private class MyWebViewClient extends WebViewClient {

  @Override
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (Uri.parse(url).getHost().equals("www.example.com")) {
        // This is my web site, so do not override; let my WebView load the page
        return false;
    }
    // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(intent);
    return true;
  }
}

In your case the code within the function should be view.loadURL(url). And from your onCreate add browser.setWebViewClient(new WebViewClient());

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top