Android Money Exchange Example with volley API



dep:

implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
implementation 'com.mcxiaoke.volley:library:1.0.19'implementation 'com.github.bumptech.glide:glide:4.8.0'

manifest:

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


ExchangeCurrencyActivity.java

 package hemanth.smartkit.com.Activity;  
 import android.app.ProgressDialog;  
 import android.content.Context;  
 import android.os.AsyncTask;  
 import android.os.Bundle;  
 import android.support.v7.app.AlertDialog;  
 import android.support.v7.app.AppCompatActivity;  
 import android.text.Editable;  
 import android.text.InputFilter;  
 import android.text.TextWatcher;  
 import android.util.Log;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.inputmethod.InputMethodManager;  
 import android.widget.AdapterView;  
 import android.widget.EditText;  
 import android.widget.ImageView;  
 import android.widget.LinearLayout;  
 import android.widget.ListView;  
 import android.widget.TextView;  
 import com.android.volley.AuthFailureError;  
 import com.android.volley.DefaultRetryPolicy;  
 import com.android.volley.Request;  
 import com.android.volley.Response;  
 import com.android.volley.VolleyError;  
 import com.android.volley.VolleyLog;  
 import com.android.volley.toolbox.JsonObjectRequest;  
 import com.android.volley.toolbox.StringRequest;  
 import com.android.volley.toolbox.Volley;  
 import com.bumptech.glide.Glide;  
 import org.json.JSONArray;  
 import org.json.JSONException;  
 import org.json.JSONObject;  
 import java.math.BigDecimal;  
 import java.util.ArrayList;  
 import java.util.Collections;  
 import java.util.Comparator;  
 import java.util.HashMap;  
 import java.util.Map;  
 import java.util.Timer;  
 import java.util.TimerTask;  
 import hemanth.smartkit.com.Adapter.BottomFlagDropDownAdapter;  
 import hemanth.smartkit.com.Adapter.TopFlagDropDownAdapter;  
 import hemanth.smartkit.com.Bean.FlagSpinnerBean;  
 import hemanth.smartkit.com.R;  
 import hemanth.smartkit.com.Utils.PreferncesUtils;  
 public class ExchangeCurrencyActivity extends AppCompatActivity {  
   public static TextView TopCurrencyTextview, BottomCurrencyTextview;  
   TextView SourceCountryTextView, DestinationCountryTextView;  
   LinearLayout LinearLayoutTopSpinner, LinearLayoutBottomSpinner,LinearLayoutTopSourceCountryTextView, LinearLayoutDestinationCountryTextView;  
   public static ImageView TopCurrencyImg, BottomCurrencyImg;  
   EditText TopEditText, BottomEditText;  
   TextView Rate, CashPayoutFee1, CashPayoutFee, AccountCreditFee;  
   ProgressDialog mprocessingdialog;  
   public ArrayList<FlagSpinnerBean> TopList = new ArrayList<FlagSpinnerBean>();  
   public ArrayList<FlagSpinnerBean> BottomList = new ArrayList<FlagSpinnerBean>();  
   EditText InputSearch;  
   ListView FlagListview;  
   TopFlagDropDownAdapter topFlagDropDownAdapter;  
   BottomFlagDropDownAdapter bottomFlagDropDownAdapter;  
   String TotalRate, INR, GBP, FromAmount, ToAmount, Commission, Cashcommission, Walletcommission, CheckStatus;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_exchange_currency);  
     TopEditText = (EditText) findViewById(R.id.TopEditText);  
     BottomEditText = (EditText) findViewById(R.id.BottomEditText);  
     TopCurrencyTextview = (TextView) findViewById(R.id.TopCurrencyTextview);  
     TopCurrencyImg = (ImageView) findViewById(R.id.TopCurrencyImg);  
     BottomCurrencyTextview = (TextView) findViewById(R.id.BottomCurrencyTextview);  
     BottomCurrencyImg = (ImageView) findViewById(R.id.BottomCurrencyImg);  
     Rate = (TextView) findViewById(R.id.Rate);  
     CashPayoutFee1 = (TextView) findViewById(R.id.CashPayoutFee1);  
     CashPayoutFee = (TextView) findViewById(R.id.CashPayoutFee);  
     AccountCreditFee = (TextView) findViewById(R.id.AccountCreditFee);  
     SourceCountryTextView = (TextView) findViewById(R.id.SourceCountryTextView);  
     LinearLayoutTopSpinner = (LinearLayout) findViewById(R.id.LinearLayoutTopSpinner);  
     LinearLayoutTopSourceCountryTextView = (LinearLayout) findViewById(R.id.LinearLayoutTopSourceCountryTextView);  
     DestinationCountryTextView = (TextView) findViewById(R.id.DestinationCountryTextView);  
     LinearLayoutBottomSpinner = (LinearLayout) findViewById(R.id.LinearLayoutBottomSpinner);  
     LinearLayoutDestinationCountryTextView = (LinearLayout) findViewById(R.id.LinearLayoutDestinationCountryTextView);  
     LinearLayoutTopSpinner.setVisibility(View.GONE);  
     LinearLayoutBottomSpinner.setVisibility(View.GONE);  
     SourceCountryTextView.setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View view) {  
         TopDropDown();  
       }  
     });  
     DestinationCountryTextView.setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View view) {  
         BottomDropDown();  
       }  
     });  
     LinearLayoutTopSpinner.setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View view) {  
         TopDropDown();  
       }  
     });  
     LinearLayoutBottomSpinner.setOnClickListener(new View.OnClickListener() {  
       @Override  
       public void onClick(View view) {  
         BottomDropDown();  
       }  
     });  
     TopEditText.addTextChangedListener(new TextWatcher() {  
       @Override  
       public void onTextChanged(CharSequence s, int start, int before, int count) {  
         try {  
           if (TopEditText.hasFocus()) {  
             TopEditText.setCursorVisible(true);  
             TopEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(19)});  
             new ExchangeCurrencyActivity.TopToBottomRateExchangetAsync().execute();  
           }  
           if (TopEditText.getText().toString().trim().length() >= 12) {  
             TopEditText.setTextSize(15);  
           } else if (TopEditText.getText().toString().trim().length() >= 8) {  
             TopEditText.setTextSize(20);  
           } else {  
             TopEditText.setTextSize(30);  
           }  
         } catch (Exception e) {  
           e.printStackTrace();  
           finish();  
           startActivity(getIntent());  
         }  
       }  
       @Override  
       public void beforeTextChanged(CharSequence s, int start, int count, int after) {  
       }  
       @Override  
       public void afterTextChanged(Editable s) {  
         try {  
           PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.FROM_AMOUNT, FromAmount);  
           PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.TO_AMOUNT, TotalRate);  
           if (TopEditText.getText().toString().trim().length() == 0) {  
             BottomEditText.getText().clear();  
             CashPayoutFee.setText("0");  
             AccountCreditFee.setText("0");  
           }  
         } catch (Exception e) {  
           e.printStackTrace();  
           finish();  
           startActivity(getIntent());  
         }  
       }  
     });  
     BottomEditText.addTextChangedListener(new TextWatcher() {  
       @Override  
       public void onTextChanged(CharSequence s, int start, int before, int count) {  
         try {  
           if (BottomEditText.hasFocus()) {  
             BottomEditText.setCursorVisible(true);  
             BottomEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(19)});  
             new ExchangeCurrencyActivity.BottomToTopRateExchangetAsync().execute();  
           }  
           if (BottomEditText.getText().toString().trim().length() >= 12) {  
             BottomEditText.setTextSize(15);  
           } else if (BottomEditText.getText().toString().trim().length() >= 8) {  
             BottomEditText.setTextSize(20);  
           } else {  
             BottomEditText.setTextSize(30);  
           }  
         } catch (Exception e) {  
           e.printStackTrace();  
           finish();  
           startActivity(getIntent());  
         }  
       }  
       @Override  
       public void beforeTextChanged(CharSequence s, int start, int count, int after) {  
       }  
       @Override  
       public void afterTextChanged(Editable s) {  
         try {  
           PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.TO_AMOUNT, ToAmount);  
           PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.FROM_AMOUNT, TotalRate);  
           if (BottomEditText.getText().toString().trim().length() == 0) {  
             TopEditText.getText().clear();  
             CashPayoutFee.setText("0");  
             AccountCreditFee.setText("0");  
           }  
         } catch (Exception e) {  
           e.printStackTrace();  
           finish();  
           startActivity(getIntent());  
         }  
       }  
     });  
     new ExchangeCurrencyActivity.GetFlagsAsync().execute();  
   }  
   private void TopDropDown() {  
     LayoutInflater li = LayoutInflater.from(this);  
     View Dialog = li.inflate(R.layout.activity_searchable_spinner_drop_down_view, null);  
     AlertDialog.Builder alert = new AlertDialog.Builder(this);  
     alert.setView(Dialog);  
     alert.setCancelable(true);  
     final AlertDialog alertDialog = alert.create();  
     alertDialog.show();  
     InputSearch = (EditText) Dialog.findViewById(R.id.inputSearch);  
     FlagListview = (ListView) Dialog.findViewById(R.id.listview);  
     Collections.sort(TopList, new Comparator<FlagSpinnerBean>() {  
       public int compare(FlagSpinnerBean o1, FlagSpinnerBean o2) {  
         if (o1.getCountry_name() == null || o2.getCountry_name() == null) {  
           return 0;  
         }  
         return o1.getCountry_name().compareToIgnoreCase(o2.getCountry_name());  
       }  
     });  
     topFlagDropDownAdapter = new TopFlagDropDownAdapter(this, TopList);  
     FlagListview.setAdapter(topFlagDropDownAdapter);  
     InputSearch.addTextChangedListener(new TextWatcher() {  
       @Override  
       public void onTextChanged(CharSequence s, int start, int before, int count) {  
         // Call back the Adapter with current character to Filter  
       }  
       @Override  
       public void beforeTextChanged(CharSequence s, int start, int count, int after) {  
       }  
       @Override  
       public void afterTextChanged(Editable s) {  
         topFlagDropDownAdapter.getFilter().filter(s.toString());  
 //        SearchableSpinnerAlternativeActivity.this.BottomAdapter.getFilter().filter(s);  
       }  
     });  
     FlagListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       @Override  
       public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {  
         final FlagSpinnerBean c = (FlagSpinnerBean) adapterView.getAdapter().getItem(i);//TopList.get(i);  
 //        Toast.makeText(SearchableSpinnerAlternativeActivity.this.getApplicationContext(), historyBean.getCountryisocode() + "\n" +historyBean.getCountry_name() + "\n" + historyBean.getCountry_code(), Toast.LENGTH_SHORT).show();  
         TopCurrencyTextview.setText(c.getCountry_code());  
         Glide.with(ExchangeCurrencyActivity.this).load(c.getCountry_image()).into(TopCurrencyImg);  
         LinearLayoutTopSourceCountryTextView.setVisibility(View.GONE);  
         LinearLayoutTopSpinner.setVisibility(View.VISIBLE);  
         PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.FROM_CODE, c.getCountry_code());  
         PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.FROM_COUNTRY, c.getCountry_name());  
         PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.SOURCE_ISO_CODE, c.getCountryisocode());  
         alertDialog.dismiss();  
         InputMethodManager inputMethodManager = (InputMethodManager)  
             getSystemService(Context.INPUT_METHOD_SERVICE);  
         inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);  
         if (TopEditText.hasFocus()) {  
           new ExchangeCurrencyActivity.TopToBottomRateExchangetAsync().execute();  
         } else if (BottomEditText.hasFocus()) {  
           new ExchangeCurrencyActivity.BottomToTopRateExchangetAsync().execute();  
         } else {  
           new ExchangeCurrencyActivity.TopToBottomRateExchangetAsync().execute();  
         }  
       }  
     });  
   }  
   private void BottomDropDown() {  
     LayoutInflater li = LayoutInflater.from(this);  
     View Dialog = li.inflate(R.layout.activity_searchable_spinner_drop_down_view, null);  
     AlertDialog.Builder alert = new AlertDialog.Builder(this);  
     alert.setView(Dialog);  
     alert.setCancelable(true);  
     final AlertDialog alertDialog = alert.create();  
     alertDialog.show();  
     InputSearch = (EditText) Dialog.findViewById(R.id.inputSearch);  
     FlagListview = (ListView) Dialog.findViewById(R.id.listview);  
     Collections.sort(BottomList, new Comparator<FlagSpinnerBean>() {  
       public int compare(FlagSpinnerBean o1, FlagSpinnerBean o2) {  
         if (o1.getCountry_name() == null || o2.getCountry_name() == null) {  
           return 0;  
         }  
         return o1.getCountry_name().compareToIgnoreCase(o2.getCountry_name());  
       }  
     });  
     bottomFlagDropDownAdapter = new BottomFlagDropDownAdapter(this, BottomList);  
     FlagListview.setAdapter(bottomFlagDropDownAdapter);  
     InputSearch.addTextChangedListener(new TextWatcher() {  
       @Override  
       public void onTextChanged(CharSequence s, int start, int before, int count) {  
         // Call back the Adapter with current character to Filter  
       }  
       @Override  
       public void beforeTextChanged(CharSequence s, int start, int count, int after) {  
       }  
       @Override  
       public void afterTextChanged(Editable s) {  
         bottomFlagDropDownAdapter.getFilter().filter(s.toString());  
       }  
     });  
     FlagListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       @Override  
       public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {  
         final FlagSpinnerBean c = (FlagSpinnerBean) adapterView.getAdapter().getItem(i);//final FlagSpinnerBean historyBean = BottomList.get(i);  
 //        Toast.makeText(SearchableSpinnerAlternativeActivity.this.getApplicationContext(), historyBean.getCountryisocode() + "\n" + historyBean.getCountry_name() + "\n" + historyBean.getCountry_code(), Toast.LENGTH_SHORT).show();  
         BottomCurrencyTextview.setText(c.getCountry_code());  
         Glide.with(ExchangeCurrencyActivity.this).load(c.getCountry_image()).into(BottomCurrencyImg);  
         LinearLayoutDestinationCountryTextView.setVisibility(View.GONE);  
         LinearLayoutBottomSpinner.setVisibility(View.VISIBLE);  
         PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.TO_CODE, c.getCountry_code());  
         PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.TO_COUNTRY, c.getCountry_name());  
         PreferncesUtils.saveStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.DESTINATION_ISO_CODE, c.getCountryisocode());  
         alertDialog.dismiss();  
         InputMethodManager inputMethodManager = (InputMethodManager)  
             getSystemService(Context.INPUT_METHOD_SERVICE);  
         inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);  
         if (TopEditText.hasFocus()) {  
           new ExchangeCurrencyActivity.TopToBottomRateExchangetAsync().execute();  
         } else if (BottomEditText.hasFocus()) {  
           new ExchangeCurrencyActivity.BottomToTopRateExchangetAsync().execute();  
         } else {  
           new ExchangeCurrencyActivity.TopToBottomRateExchangetAsync().execute();  
         }  
       }  
     });  
   }  
   private class GetFlagsAsync extends AsyncTask<Void, Void, Void> {  
     @Override  
     protected void onPreExecute() {  
       // TODO Auto-generated method stub  
       super.onPreExecute();  
       mprocessingdialog = new ProgressDialog(ExchangeCurrencyActivity.this);  
       mprocessingdialog.setTitle("Please Wait..");  
       mprocessingdialog.setMessage("Loading");  
       mprocessingdialog.setIndeterminate(true);  
       mprocessingdialog.setCancelable(false);  
       mprocessingdialog.show();  
     }  
     @Override  
     protected Void doInBackground(Void... arg0) {  
       StringRequest stringRequest = new StringRequest(Request.Method.GET, "http://54.200.111.119:6099/Crosspaydevelopment/upload/getCountry",  
           new Response.Listener<String>() {  
             @Override  
             public void onResponse(String response) {  
               Log.e("rlog", "response" + response);  
               try {  
                 JSONObject jsonObj = new JSONObject(response);  
                 JSONArray jsonArray = jsonObj.getJSONArray("country");  
                 for (int i = 0; i <= jsonArray.length(); i++) {  
                   JSONObject c = jsonArray.getJSONObject(i);  
                   FlagSpinnerBean item = new FlagSpinnerBean();  
 //                  Log.e("rlog1", "response" + response);  
                   if (c.getString("country_status").equals("2") || c.getString("country_status").equals("3")) {  
 //                    String icon = c.getString("country_image");  
                     item.setCountry_image(c.getString("country_image"));  
                     item.setCountry_code(c.optString("country_code"));  
                     item.setCountry_name(c.optString("country_name"));  
                     item.setCountryisocode(c.optString("countryisocode"));  
                     TopList.add(item);  
                   }  
                   if (c.getString("country_status").equals("1") || c.getString("country_status").equals("2")) {  
 //                    String icon = c.getString("country_image");  
                     item.setCountry_image(c.getString("country_image"));  
                     item.setCountry_code(c.optString("country_code"));  
                     item.setCountry_name(c.optString("country_name"));  
                     item.setCountryisocode(c.optString("countryisocode"));  
                     BottomList.add(item);  
                   }  
                 }  
 //                for (int i = 0; i < jsonArray.length(); i++) {  
 //                  for (int j = 0; j < Topspinnerarray.size(); j++) {  
 //                    FlagSpinnerBean item = new FlagSpinnerBean();  
 //                    JSONObject c = jsonArray.getJSONObject(i);  
 ////                    if (c.getString("country_name").equals(Topspinnerarray.get(j))) {  
 ////                    if (c.getString("country_status").equals("2"))  
 //                    if (c.getString("country_status").equals("2") || c.getString("country_status").equals("3")) {  
 //                      String icon = c.getString("country_image");  
 //                      item.setCountry_image(icon);  
 //                      item.setCountry_code(c.optString("country_code"));  
 //                      item.setCountry_name(c.optString("country_name"));  
 //                      item.setCountryisocode(c.optString("countryisocode"));  
 //                      data1.add(item);  
 ////                      data0.add(c.getString("country_code"));  
 //                      break;  
 ////                      }  
 //                    }  
 //                  }  
 //                }  
 //  
 //                for (int i = 0; i < jsonArray.length(); i++) {  
 //                  for (int j = 0; j < Bottomspinnerarray.size(); j++) {  
 //                    FlagSpinnerBean item = new FlagSpinnerBean();  
 //                    JSONObject c = jsonArray.getJSONObject(i);  
 ////                    if (c.getString("country_name").equals(Bottomspinnerarray.get(j))) {  
 //                    if (c.getString("country_status").equals("1") || c.getString("country_status").equals("2")) {  
 //                      String icon = c.getString("country_image");  
 //                      item.setCountry_image(icon);  
 //                      item.setCountry_code(c.optString("country_code"));  
 //                      item.setCountry_name(c.optString("country_name"));  
 //                      item.setCountryisocode(c.optString("countryisocode"));  
 //  
 //                      data2.add(item);  
 //                      break;  
 ////                      }  
 //                    }  
 //                  }  
 //                }  
 //                ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(MainActivity.this,  
 //                    android.R.layout.select_dialog_item, data0);  
 //                dataAdapter.setDropDownViewResource(android.R.layout.select_dialog_item);  
 //                dataAdapter.notifyDataSetChanged();  
 //                TopSpinner.setAdapter(dataAdapter);  
 //  
 //  
 //                Collections.sort(data1, new Comparator<FlagSpinnerBean>() {  
 //                  public int compare(FlagSpinnerBean o1, FlagSpinnerBean o2) {  
 //                    if (o1.getCountry_name() == null || o2.getCountry_name() == null) {  
 //                      return 0;  
 //                    }  
 //  
 //                    return o1.getCountry_name().compareToIgnoreCase(o2.getCountry_name());  
 //                  }  
 //                });  
 //  
 //                CustomListAdapter = new FlagSpinnerDropDownAdapter(MainActivity.this, data1);  
 //                TopSpinner.setAdapter(CustomListAdapter);  
 ////                Collections.reverse(data1);  
 ////                TopSpinner.setSelection(12);  
 ////                TopSpinner.getAdapter().notify();  
 ////                TopSpinner.setSelection(1000);  
 //                TopSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {  
 //                  @SuppressLint("WrongConstant")  
 //                  @Override  
 //                  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {  
 //  
 //  
 //                    FlagSpinnerBean c = data1.get(position);  
 ////                    updateGUI1();  
 //                    PreferncesUtils.saveStringValue(MainActivity.this, PreferncesUtils.FROM_CODE, c.getCountry_code());  
 //                    PreferncesUtils.saveStringValue(MainActivity.this, PreferncesUtils.FROM_COUNTRY, c.getCountry_name());  
 //                    PreferncesUtils.saveStringValue(MainActivity.this, PreferncesUtils.SOURCE_ISO_CODE, c.getCountryisocode());  
 ////                  Toast.makeText(getApplicationContext(),c.getCountry_name()+"\n"+c.getCountry_code()+"\n",Toast.LENGTH_SHORT).show();  
 //                    InputMethodManager inputMethodManager = (InputMethodManager)  
 //                        getSystemService(Context.INPUT_METHOD_SERVICE);  
 //                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);  
 //  
 //  
 ////                    Toast.makeText(getApplicationContext(),data1.get(position).toString(),Toast.LENGTH_SHORT).show();  
 //  
 ////                    Calendar calendar = Calendar.getInstance();  
 ////                    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss ");  
 ////                    if(c.getCountry_name().equalsIgnoreCase("United kingdom")){  
 ////                      sdf.setTimeZone(TimeZone.getTimeZone("GMT+1"));  
 ////                      Log.e("rlog",sdf.format(calendar.getTime()));  
 ////                    }else {  
 ////  
 ////                      sdf.setTimeZone(TimeZone.getTimeZone("GMT+2"));  
 ////                      Log.e("rlog",sdf.format(calendar.getTime()));  
 ////  
 ////                    }  
 //  
 //  
 //                    if (TopEditText.hasFocus()) {  
 //                      new MainActivity.TopToBottomRateExchangetAsync().execute();  
 //                    } else if (BottomEditText.hasFocus()) {  
 //                      new MainActivity.BottomToTopRateExchangetAsync().execute();  
 //                    } else {  
 //                      new MainActivity.TopToBottomRateExchangetAsync().execute();  
 //                    }  
 ////                    new MainActivity.TopToBottomRateExchangetAsync().execute();  
 ////                    BottomEditText.requestFocus();  
 //  
 //                  }  
 //  
 //                  @Override  
 //                  public void onNothingSelected(AdapterView<?> parent) {  
 ////                    TopSpinner.setSelection(-1);  
 //                  }  
 //                });  
 //                Collections.sort(data2, new Comparator<FlagSpinnerBean>() {  
 //                  public int compare(FlagSpinnerBean o1, FlagSpinnerBean o2) {  
 //                    if (o1.getCountry_name() == null || o2.getCountry_name() == null) {  
 //                      return 0;  
 //                    }  
 //  
 //                    return o1.getCountry_name().compareToIgnoreCase(o2.getCountry_name());  
 //                  }  
 //                });  
 //                CustomListAdapter = new FlagSpinnerDropDownAdapter(MainActivity.this, data2);  
 //                BottomSpinner.setAdapter(CustomListAdapter);  
 //  
 ////                BottomSpinner.setSelection(17);  
 ////                BottomSpinner.setSelection(2000);  
 //                BottomSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {  
 //                  @Override  
 //                  public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {  
 //  
 //  
 //                    FlagSpinnerBean c = data2.get(position);  
 ////                    updateGUI2();  
 //                    PreferncesUtils.saveStringValue(MainActivity.this, PreferncesUtils.TO_CODE, c.getCountry_code());  
 //                    PreferncesUtils.saveStringValue(MainActivity.this, PreferncesUtils.TO_COUNTRY, c.getCountry_name());  
 //                    PreferncesUtils.saveStringValue(MainActivity.this, PreferncesUtils.DESTINATION_ISO_CODE, c.getCountryisocode());  
 ////                  Toast.makeText(getApplicationContext(),c.getCountry_name()+"\n"+c.getCountry_code()+"\n",Toast.LENGTH_SHORT).show();  
 //                    InputMethodManager inputMethodManager = (InputMethodManager)  
 //                        getSystemService(Context.INPUT_METHOD_SERVICE);  
 //                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);  
 //  
 //  
 //                    if (TopEditText.hasFocus()) {  
 //                      new MainActivity.TopToBottomRateExchangetAsync().execute();  
 //                    } else if (BottomEditText.hasFocus()) {  
 //                      new MainActivity.BottomToTopRateExchangetAsync().execute();  
 //                    } else {  
 //                      new MainActivity.TopToBottomRateExchangetAsync().execute();  
 //                    }  
 ////                    new MainActivity.TopToBottomRateExchangetAsync().execute();  
 ////                    TopEditText.requestFocus();  
 //  
 //  
 //                  }  
 //  
 //                  @Override  
 //                  public void onNothingSelected(AdapterView<?> parent) {  
 ////                    BottomSpinner.setSelection(-1);  
 //                  }  
 //                });  
               } catch (Exception e) {  
                 e.printStackTrace();  
               }  
             }  
           }, new Response.ErrorListener() {  
         @Override  
         public void onErrorResponse(VolleyError error) {  
         }  
       });  
 //      requestQueue.add(stringRequest);  
       stringRequest.setRetryPolicy(new DefaultRetryPolicy(0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));  
       Volley.newRequestQueue(ExchangeCurrencyActivity.this).add(stringRequest);  
       return null;  
     }  
     @Override  
     protected void onPostExecute(Void result) {  
       // TODO Auto-generated method stub  
       super.onPostExecute(result);  
       new Timer().schedule(new TimerTask() {  
         @Override  
         public void run() {  
           mprocessingdialog.dismiss();  
         }  
       }, 5000);  
     }  
   }  
   private class TopToBottomRateExchangetAsync extends AsyncTask<Void, Void, Void> {  
     final String ccyfrom = PreferncesUtils.loadStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.FROM_CODE, "");  
     final String ccyto = PreferncesUtils.loadStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.TO_CODE, "");  
     final String fromvalue = TopEditText.getText().toString().trim().replace(",", "");  
     @Override  
     protected void onPreExecute() {  
       // TODO Auto-generated method stub  
       super.onPreExecute();  
 //      mprocessingdialog = new ProgressDialog(MainActivity.this);  
 //      mprocessingdialog.setTitle("Please Wait..");  
 //      mprocessingdialog.setMessage("Loading");  
 //      mprocessingdialog.setIndeterminate(true);  
 //      mprocessingdialog.show();  
     }  
     @Override  
     protected Void doInBackground(Void... arg0) {  
       JSONObject params = new JSONObject();  
       try {  
         params.put("ccyfrom", ccyfrom);  
         params.put("ccyto", ccyto);  
         params.put("fromvalue", fromvalue);  
         params.put("source", "Android");  
         Log.e("rlog", params.toString());  
       } catch (JSONException e) {  
         e.printStackTrace();  
       }  
       JsonObjectRequest jsonObjReq = new JsonObjectRequest(  
           Request.Method.POST, "http://54.200.111.119:6099/Crosspaydevelopment/upload/getExchangeRate", params,  
           new Response.Listener<JSONObject>() {  
             @Override  
             public void onResponse(JSONObject response) {  
               try {  
                 String res = response.toString();  
                 Log.e("rlog", res);  
                 JSONObject jsonObject = new JSONObject(res);  
                 String status = jsonObject.optString("status");  
                 String mMsg = jsonObject.optString("message");  
                 Log.e("rlog", status.toString() + mMsg.toString());  
                 if (status.equals("200")) {  
 //                  Toast.makeText(MainActivity.this, mMsg.toString(), Toast.LENGTH_LONG).show();  
                   INR = jsonObject.getString("INR");  
                   Rate.setText(" 1 " + ccyfrom + " = " + INR + " " + ccyto);  
                   TotalRate = jsonObject.getString("TotalRate");  
                   BigDecimal d = new BigDecimal(TotalRate);  
                   BottomEditText.setText(d.toString());  
                 } else {  
 //                  Toast.makeText(MainActivity.this, mMsg.toString(), Toast.LENGTH_LONG).show();  
                 }  
               } catch (Exception e) {  
                 e.printStackTrace();  
               }  
             }  
           }, new Response.ErrorListener() {  
         @Override  
         public void onErrorResponse(VolleyError error) {  
           VolleyLog.e("rlog", "Error: " + error.getMessage());  
         }  
       }) {  
         /**  
          * Passing some request headers  
          */  
         @Override  
         public Map<String, String> getHeaders() throws AuthFailureError {  
           HashMap<String, String> headers = new HashMap<String, String>();  
           headers.put("Content-Type", "application/json; charset=utf-8");  
           return headers;  
         }  
       };  
       jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));  
       Volley.newRequestQueue(ExchangeCurrencyActivity.this).add(jsonObjReq);  
       return null;  
     }  
     @Override  
     protected void onPostExecute(Void result) {  
       // TODO Auto-generated method stub  
       super.onPostExecute(result);  
 //      mprocessingdialog.dismiss();  
     }  
   }  
   private class BottomToTopRateExchangetAsync extends AsyncTask<Void, Void, Void> {  
     final String ccyfrom = PreferncesUtils.loadStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.FROM_CODE, "");  
     final String ccyto = PreferncesUtils.loadStringValue(ExchangeCurrencyActivity.this, PreferncesUtils.TO_CODE, "");  
     final String fromvalue = BottomEditText.getText().toString().trim().replace(",", "");  
     @Override  
     protected void onPreExecute() {  
       // TODO Auto-generated method stub  
       super.onPreExecute();  
 //      mprocessingdialog = new ProgressDialog(MainActivity.this);  
 //      mprocessingdialog.setTitle("Please Wait..");  
 //      mprocessingdialog.setMessage("Loading");  
 //      mprocessingdialog.setIndeterminate(true);  
 //      mprocessingdialog.show();  
     }  
     @Override  
     protected Void doInBackground(Void... arg0) {  
       JSONObject params = new JSONObject();  
       try {  
         params.put("ccyfrom", ccyfrom);  
         params.put("ccyto", ccyto);  
         params.put("tovalue", fromvalue);  
         params.put("source", "Android");  
         Log.e("rlog", params.toString());  
       } catch (JSONException e) {  
         e.printStackTrace();  
       }  
       JsonObjectRequest jsonObjReq = new JsonObjectRequest(  
           Request.Method.POST, "http://54.200.111.119:6099/Crosspaydevelopment/upload/getExchangeRateReverse", params,  
           new Response.Listener<JSONObject>() {  
             @Override  
             public void onResponse(JSONObject response) {  
               try {  
                 String res = response.toString();  
                 Log.e("rlog", res);  
                 JSONObject jsonObject = new JSONObject(res);  
                 String status = jsonObject.optString("status");  
                 String mMsg = jsonObject.optString("message");  
                 Log.e("rlog", status.toString() + mMsg.toString());  
                 if (status.equals("200")) {  
                   //                  Toast.makeText(MainActivity.this, mMsg.toString(), Toast.LENGTH_LONG).show();  
                   INR = jsonObject.getString("INR");  
                   Rate.setText(" 1 " + ccyfrom + " = " + INR + " " + ccyto);  
                   TotalRate = jsonObject.getString("TotalRate");  
                   BigDecimal d = new BigDecimal(TotalRate);  
                   TopEditText.setText(d.toString());  
                 } else {  
                   //                  Toast.makeText(MainActivity.this, mMsg.toString(), Toast.LENGTH_LONG).show();  
                 }  
               } catch (Exception e) {  
                 e.printStackTrace();  
               }  
             }  
           }, new Response.ErrorListener() {  
         @Override  
         public void onErrorResponse(VolleyError error) {  
           VolleyLog.e("rlog", "Error: " + error.getMessage());  
         }  
       }) {  
         /**  
          * Passing some request headers  
          */  
         @Override  
         public Map<String, String> getHeaders() throws AuthFailureError {  
           HashMap<String, String> headers = new HashMap<String, String>();  
           headers.put("Content-Type", "application/json; charset=utf-8");  
           return headers;  
         }  
       };  
       jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(0, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));  
       Volley.newRequestQueue(ExchangeCurrencyActivity.this).add(jsonObjReq);  
       return null;  
     }  
     @Override  
     protected void onPostExecute(Void result) {  
       // TODO Auto-generated method stub  
       super.onPostExecute(result);  
 //      mprocessingdialog.dismiss();  
     }  
   }  
 }  


TopFlagDropDownAdapter.java

 package hemanth.smartkit.com.Adapter;  
 import android.app.Activity;  
 import android.content.Context;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.BaseAdapter;  
 import android.widget.Filter;  
 import android.widget.Filterable;  
 import android.widget.ImageView;  
 import android.widget.TextView;  
 import com.bumptech.glide.Glide;  
 import java.util.ArrayList;  
 import java.util.List;  
 import java.util.Locale;  
 import hemanth.smartkit.com.Bean.FlagSpinnerBean;  
 import hemanth.smartkit.com.R;  
 public class TopFlagDropDownAdapter extends BaseAdapter implements Filterable {  
   private Activity activity;  
   private LayoutInflater inflater;  
   List<FlagSpinnerBean> list;  
   public static List<FlagSpinnerBean> searchlist;  
   public TopFlagDropDownAdapter(Activity activity, List<FlagSpinnerBean> list) {  
     this.activity = activity;  
     this.list = list;  
   }  
   public class ViewHolder {  
     TextView txt;  
     ImageView img;  
   }  
   @Override  
   public int getCount() {  
     return list.size();  
   }  
   @Override  
   public Object getItem(int location) {  
     return list.get(location);  
   }  
   @Override  
   public long getItemId(int position) {  
     return position;  
   }  
   @Override  
   public View getView(final int position, View convertView, ViewGroup parent) {  
     final ViewHolder holder;  
     holder = new ViewHolder();  
     if (inflater == null)  
       inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
     if (convertView == null)  
       convertView = inflater.inflate(R.layout.flag_spinner_list_dropdownview, null);  
     holder.txt = (TextView) convertView.findViewById(R.id.txt);  
     holder.img = (ImageView) convertView.findViewById(R.id.img);  
     FlagSpinnerBean historybean = list.get(position);  
     Glide.with(activity).load(historybean.getCountry_image()).into(holder.img);  
     holder.txt.setText(historybean.getCountry_name());  
     return convertView;  
   }  
   @Override  
   public Filter getFilter() {  
     Filter filter = new Filter() {  
       @SuppressWarnings("unchecked")  
       @Override  
       protected void publishResults(CharSequence constraint, FilterResults results) {  
         if (results.count == 0) {  
           notifyDataSetInvalidated();  
         } else {  
           list = (ArrayList<FlagSpinnerBean>) results.values; // has  
           notifyDataSetChanged();  
         }  
       }  
       @Override  
       protected FilterResults performFiltering(CharSequence constraint) {  
         FilterResults results = new FilterResults(); // Holds the  
         // results of a  
         // filtering  
         // operation in  
         // values  
         // List<String> FilteredArrList = new ArrayList<String>();  
         List<FlagSpinnerBean> FilteredArrList = new ArrayList<FlagSpinnerBean>();  
         if (searchlist == null) {  
           searchlist = new ArrayList<FlagSpinnerBean>(list); // saves  
         }  
         /********  
          *  
          * If constraint(CharSequence that is received) is null returns  
          * the mOriginalValues(Original) values else does the Filtering  
          * and returns FilteredArrList(Filtered)  
          *  
          ********/  
         if (constraint == null || constraint.length() == 0) {  
           // set the Original result to return  
           results.count = searchlist.size();  
           results.values = searchlist;  
         } else {  
           Locale locale = Locale.getDefault();  
           constraint = constraint.toString().toLowerCase(locale);  
           for (int i = 0; i < searchlist.size(); i++) {  
             FlagSpinnerBean model = searchlist.get(i);  
             String SearchName = model.getCountry_name();  
 //            String SearchDate = model.getTxn_date();  
 //            String SearchIFSC = model.getIfsc();  
             if (SearchName.toLowerCase(locale).contains(constraint.toString())) {  
               FilteredArrList.add(model);  
 //              FilteredArrList.get(i)  
 //              list.get(i);  
 //              Toast.makeText(activity,"1" , Toast.LENGTH_SHORT).show();  
             }  
           }  
           // set the Filtered result to return  
           results.count = FilteredArrList.size();  
           results.values = FilteredArrList;  
         }  
         return results;  
       }  
     };  
     return filter;  
   }  
 }  


BottomFlagDropDownAdapter.java

package hemanth.smartkit.com.Adapter;  
 import android.app.Activity;  
 import android.content.Context;  
 import android.view.LayoutInflater;  
 import android.view.View;  
 import android.view.ViewGroup;  
 import android.widget.BaseAdapter;  
 import android.widget.Filter;  
 import android.widget.Filterable;  
 import android.widget.ImageView;  
 import android.widget.TextView;  
 import com.bumptech.glide.Glide;  
 import java.util.ArrayList;  
 import java.util.List;  
 import java.util.Locale;  
 import hemanth.smartkit.com.Bean.FlagSpinnerBean;  
 import hemanth.smartkit.com.R;  
 public class BottomFlagDropDownAdapter extends BaseAdapter implements Filterable {  
   private Activity activity;  
   private LayoutInflater inflater;  
   List<FlagSpinnerBean> list;  
   public static List<FlagSpinnerBean> searchlist;  
   public BottomFlagDropDownAdapter(Activity activity, List<FlagSpinnerBean> list) {  
     this.activity = activity;  
     this.list = list;  
   }  
   public class ViewHolder {  
     TextView txt;  
     ImageView img;  
   }  
   @Override  
   public int getCount() {  
     return list.size();  
   }  
   @Override  
   public Object getItem(int location) {  
     return list.get(location);  
   }  
   @Override  
   public long getItemId(int position) {  
     return position;  
   }  
   @Override  
   public View getView(final int position, View convertView, ViewGroup parent) {  
     final ViewHolder holder;  
     holder = new ViewHolder();  
     if (inflater == null)  
       inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
     if (convertView == null)  
       convertView = inflater.inflate(R.layout.flag_spinner_list_dropdownview, null);  
     holder.txt = (TextView) convertView.findViewById(R.id.txt);  
     holder.img = (ImageView) convertView.findViewById(R.id.img);  
     FlagSpinnerBean historybean = list.get(position);  
     Glide.with(activity).load(historybean.getCountry_image()).into(holder.img);  
     holder.txt.setText(historybean.getCountry_name());  
     return convertView;  
   }  
   @Override  
   public Filter getFilter() {  
     Filter filter = new Filter() {  
       @SuppressWarnings("unchecked")  
       @Override  
       protected void publishResults(CharSequence constraint, FilterResults results) {  
         if (results.count == 0) {  
           notifyDataSetInvalidated();  
         } else {  
           list = (ArrayList<FlagSpinnerBean>) results.values; // has  
           notifyDataSetChanged();  
         }  
       }  
       @Override  
       protected FilterResults performFiltering(CharSequence constraint) {  
         FilterResults results = new FilterResults(); // Holds the  
         // results of a  
         // filtering  
         // operation in  
         // values  
         // List<String> FilteredArrList = new ArrayList<String>();  
         List<FlagSpinnerBean> FilteredArrList = new ArrayList<FlagSpinnerBean>();  
         if (searchlist == null) {  
           searchlist = new ArrayList<FlagSpinnerBean>(list); // saves  
         }  
         /********  
          *  
          * If constraint(CharSequence that is received) is null returns  
          * the mOriginalValues(Original) values else does the Filtering  
          * and returns FilteredArrList(Filtered)  
          *  
          ********/  
         if (constraint == null || constraint.length() == 0) {  
           // set the Original result to return  
           results.count = searchlist.size();  
           results.values = searchlist;  
         } else {  
           Locale locale = Locale.getDefault();  
           constraint = constraint.toString().toLowerCase(locale);  
           for (int i = 0; i < searchlist.size(); i++) {  
             FlagSpinnerBean model = searchlist.get(i);  
             String SearchName = model.getCountry_name();  
 //            String SearchDate = model.getTxn_date();  
 //            String SearchIFSC = model.getIfsc();  
             if (SearchName.toLowerCase(locale).contains(constraint.toString())) {  
               FilteredArrList.add(model);  
 //              FilteredArrList.get(i)  
 //              list.get(i);  
 //              Toast.makeText(activity,"1" , Toast.LENGTH_SHORT).show();  
             }  
           }  
           // set the Filtered result to return  
           results.count = FilteredArrList.size();  
           results.values = FilteredArrList;  
         }  
         return results;  
       }  
     };  
     return filter;  
   }  
 }  



FlagSpinnerBean.java

package hemanth.smartkit.com.Bean;  
 public class FlagSpinnerBean {  
   String country_code;  
   String country_name;  
   String country_image;  
   String countryisocode ;  
   public String getCountryisocode() {  
     return countryisocode;  
   }  
   public void setCountryisocode(String countryisocode) {  
     this.countryisocode = countryisocode;  
   }  
   public String getCountry_code() {  
     return country_code;  
   }  
   public void setCountry_code(String country_code) {  
     this.country_code = country_code;  
   }  
   public String getCountry_name() {  
     return country_name;  
   }  
   public void setCountry_name(String country_name) {  
     this.country_name = country_name;  
   }  
   public String getCountry_image() {  
     return country_image;  
   }  
   public void setCountry_image(String country_image) {  
     this.country_image = country_image;  
   }  
 }  



PreferncesUtils.java

 package hemanth.smartkit.com.Utils;  
 import android.content.Context;  
 import android.content.SharedPreferences;  
 public class PreferncesUtils {  
   public static final String PREFERENCE_NAME = "hemanth";  
   public static final String FROM_CODE = "fromcode";  
   public static final String TO_CODE = "tocode";  
   public static final String FROM_COUNTRY = "fromcountry";  
   public static final String TO_COUNTRY = "tocountry";  
   public static final String FROM_AMOUNT = "fromamount";  
   public static final String TO_AMOUNT = "toamount";  
   public static final String SOURCE_ISO_CODE = "sourcecountryisocode";  
   public static final String DESTINATION_ISO_CODE = "destinationcountryisocode";  
   public static void saveFloatValue(Context context, String key, float value) {  
     SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).edit();  
     editor.putFloat(key, value);  
     editor.apply();  
   }  
   public static float loadFloatValue(Context mContext, String from, float defValue) {  
     return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).getFloat(from, defValue);  
   }  
   public static void saveLongValue(Context context, String key, long value) {  
     SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).edit();  
     editor.putLong(key, value);  
     editor.apply();  
   }  
   public static long loadLongValue(Context mContext, String from, long defValue) {  
     return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).getLong(from, defValue);  
   }  
   //SharedPreferences String  
   public static void saveStringValue(Context context, String key, String value) {  
     SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).edit();  
     editor.putString(key, value);  
     editor.apply();  
   }  
   //  PreferncesUtils.saveStringValue(LoginActivity.this,PreferncesUtils.PHONE_NUMBER,phonenumber);  
 //  String phonenumber  = PreferncesUtils.loadStringValue(LoginActivity.this,PreferncesUtils.PHONE_NUMBER,"");  
   public static String loadStringValue(Context mContext, String from, String defValue) {  
     return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).getString(from, defValue);  
   }  
   //SharedPreferences Integer  
   public static void saveIntegerValue(Context context, String key, int value) {  
     SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).edit();  
     editor.putInt(key, value);  
     editor.apply();  
   }  
   //  PreferncesUtils.saveIntegerValue(IntroActivity.this,PreferncesUtils.INTRO_ACTIVITY,01);  
 //  int intro_value=PreferncesUtils.loadIntegerValue(SplashActivity.this,PreferncesUtils.INTRO_ACTIVITY,0);  
   public static int loadIntegerValue(Context mContext, String from, int defValue) {  
     return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).getInt(from, defValue);  
   }  
   //SharedPreferences Boolean  
   public static void saveBooleanValue(Context context, String key, boolean value) {  
     SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).edit();  
     editor.putBoolean(key, value);  
     editor.apply();  
   }  
   //  PreferncesUtils.saveBooleanValue(IntroActivity.this,PreferncesUtils.INTRO_ACTIVITY,true);  
 //  Boolean intro_value=PreferncesUtils.loadBooleanValue(IntroActivity.this,PreferncesUtils.INTRO_ACTIVITY,false);  
   public static boolean loadBooleanValue(Context mContext, String from, boolean defValue) {  
     return mContext.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE).getBoolean(from, defValue);  
   }  
 }  



activity_exchange_currency.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   tools:context=".Activity.ExchangeCurrencyActivity">  
   <LinearLayout  
     android:id="@+id/SecondLayoutLinearLayout"  
     android:layout_width="match_parent"  
     android:layout_height="809dp"  
     android:layout_margin="5dp"  
     android:background="@color/colorAccent"  
     android:orientation="vertical">  
     <ScrollView  
       android:layout_width="match_parent"  
       android:layout_height="match_parent"  
       android:layout_margin="5dp"  
       android:fillViewport="true"  
       android:orientation="vertical"  
       android:scrollbars="none">  
       <LinearLayout  
         android:layout_width="match_parent"  
         android:layout_height="wrap_content"  
         android:fitsSystemWindows="true"  
         android:orientation="vertical">  
         <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
           android:layout_width="match_parent"  
           android:layout_height="wrap_content"  
           android:layout_margin="10dp"  
           android:gravity="center">  
           <TextView  
             android:id="@+id/Rate1"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_margin="5dp"  
             android:text="Rate"  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="14sp" />  
           <TextView  
             android:id="@+id/Rate"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_margin="5dp"  
             android:layout_toRightOf="@id/Rate1"  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="14sp" />  
         </RelativeLayout>  
         <View  
           android:layout_width="match_parent"  
           android:layout_height="1dp"  
           android:background="@color/colorPrimaryDark" />  
         <TableRow  
           android:id="@+id/TopTableRow"  
           android:layout_width="match_parent"  
           android:layout_height="50dp"  
           android:layout_margin="5dp"  
           android:descendantFocusability="beforeDescendants"  
           android:focusableInTouchMode="true"  
           android:weightSum="2">  
           <EditText  
             android:id="@+id/TopEditText"  
             android:layout_width="match_parent"  
             android:layout_height="50dp"  
             android:layout_weight="2"  
             android:background="@android:color/transparent"  
             android:cursorVisible="false"  
             android:gravity="center"  
             android:hint="enterAmount"  
             android:imeOptions="actionDone"  
             android:inputType="numberDecimal"  
             android:maxLength="100"  
             android:textColor="@color/colorPrimaryDark"  
             android:textColorHint="@color/colorPrimaryDark"  
             android:textSize="20dp"  
             android:textStyle="bold" />  
           <LinearLayout  
             android:id="@+id/LinearLayoutTopSpinner"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_weight="1">  
             <!--<Spinner-->  
             <!--android:id="@+id/TopSpinner"-->  
             <!--android:layout_width="wrap_content"-->  
             <!--android:layout_height="50dp"-->  
             <!--android:spinnerMode="dialog" />-->  
             <TextView  
               android:id="@+id/TopCurrencyTextview"  
               android:layout_width="wrap_content"  
               android:layout_height="wrap_content"  
               android:layout_margin="5dp"  
               android:text="GBP"  
               android:textAllCaps="true"  
               android:textColor="@android:color/white"  
               android:textSize="30sp"  
               android:textStyle="bold" />  
             <View  
               android:layout_width="1dp"  
               android:layout_height="wrap_content"  
               android:background="@color/colorPrimaryDark" />  
             <ImageView  
               android:id="@+id/TopCurrencyImg"  
               android:layout_width="70dp"  
               android:layout_height="40dp"  
               android:layout_margin="5dp" />  
             <ImageView  
               android:layout_width="wrap_content"  
               android:layout_height="wrap_content"  
               android:layout_gravity="center"  
               android:background="@android:drawable/arrow_down_float" />  
           </LinearLayout>  
           <LinearLayout  
             android:id="@+id/LinearLayoutTopSourceCountryTextView"  
             android:layout_width="150dp"  
             android:layout_height="wrap_content"  
             android:layout_weight="1">  
             <View  
               android:layout_width="1dp"  
               android:layout_height="wrap_content"  
               android:background="@color/colorPrimaryDark" />  
             <TextView  
               android:id="@+id/SourceCountryTextView"  
               android:layout_width="match_parent"  
               android:layout_height="50dp"  
               android:gravity="center"  
               android:text="SELECTSOURCECOUNTRY"  
               android:textColor="@color/colorPrimaryDark"  
               android:textSize="12sp"  
               android:textStyle="bold" />  
           </LinearLayout>  
         </TableRow>  
         <View  
           android:layout_width="match_parent"  
           android:layout_height="1dp"  
           android:background="@color/colorPrimaryDark" />  
         <TableRow  
           android:id="@+id/BottomTableRow"  
           android:layout_width="match_parent"  
           android:layout_height="50dp"  
           android:layout_margin="5dp"  
           android:descendantFocusability="beforeDescendants"  
           android:focusableInTouchMode="true"  
           android:weightSum="2">  
           <EditText  
             android:id="@+id/BottomEditText"  
             android:layout_width="match_parent"  
             android:layout_height="50dp"  
             android:layout_weight="2"  
             android:background="@android:color/transparent"  
             android:cursorVisible="false"  
             android:gravity="center"  
             android:hint="enterAmount"  
             android:imeOptions="actionDone"  
             android:inputType="numberDecimal"  
             android:maxLength="100"  
             android:textColor="@color/colorPrimaryDark"  
             android:textColorHint="@color/colorPrimaryDark"  
             android:textSize="20dp"  
             android:textStyle="bold" />  
           <LinearLayout  
             android:id="@+id/LinearLayoutBottomSpinner"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_weight="1">  
             <!--<Spinner-->  
             <!--android:id="@+id/BottomSpinner"-->  
             <!--android:layout_width="wrap_content"-->  
             <!--android:layout_height="50dp"-->  
             <!--android:spinnerMode="dialog" />-->  
             <TextView  
               android:id="@+id/BottomCurrencyTextview"  
               android:layout_width="wrap_content"  
               android:layout_height="wrap_content"  
               android:layout_margin="5dp"  
               android:text="GBP"  
               android:textAllCaps="true"  
               android:textColor="@android:color/white"  
               android:textSize="30sp"  
               android:textStyle="bold" />  
             <View  
               android:layout_width="1dp"  
               android:layout_height="wrap_content"  
               android:background="@color/colorPrimaryDark" />  
             <ImageView  
               android:id="@+id/BottomCurrencyImg"  
               android:layout_width="70dp"  
               android:layout_height="40dp"  
               android:layout_margin="5dp" />  
             <ImageView  
               android:layout_width="wrap_content"  
               android:layout_height="wrap_content"  
               android:layout_gravity="center"  
               android:background="@android:drawable/arrow_down_float" />  
           </LinearLayout>  
           <LinearLayout  
             android:id="@+id/LinearLayoutDestinationCountryTextView"  
             android:layout_width="150dp"  
             android:layout_height="wrap_content"  
             android:layout_weight="1">  
             <View  
               android:layout_width="1dp"  
               android:layout_height="wrap_content"  
               android:background="@color/colorPrimaryDark" />  
             <TextView  
               android:id="@+id/DestinationCountryTextView"  
               android:layout_width="match_parent"  
               android:layout_height="50dp"  
               android:gravity="center"  
               android:text="SELECTDESTINATIONCOUNTRY"  
               android:textColor="@color/colorPrimaryDark"  
               android:textSize="12sp"  
               android:textStyle="bold" />  
           </LinearLayout>  
         </TableRow>  
         <View  
           android:layout_width="match_parent"  
           android:layout_height="1dp"  
           android:layout_marginBottom="5dp"  
           android:background="@color/colorPrimaryDark" />  
         <TableRow  
           android:layout_width="match_parent"  
           android:layout_height="wrap_content"  
           android:layout_margin="10dp">  
           <TextView  
             android:layout_width="match_parent"  
             android:layout_height="wrap_content"  
             android:layout_marginTop="10dp"  
             android:gravity="center"  
             android:text="Transfer"  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="15sp" />  
         </TableRow>  
         <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
           android:layout_width="match_parent"  
           android:layout_height="wrap_content"  
           android:gravity="center">  
           <TextView  
             android:id="@+id/CashPayoutFee1"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_marginBottom="10dp"  
             android:gravity="center_vertical"  
             android:text="CashPayoutFee"  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="14sp" />  
           <TextView  
             android:id="@+id/CashPayoutFee"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_marginBottom="10dp"  
             android:layout_toRightOf="@id/CashPayoutFee1"  
             android:gravity="center_vertical"  
             android:text=""  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="14sp" />  
           <TextView  
             android:id="@+id/AccountCreditFee1"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_marginLeft="20dp"  
             android:layout_marginBottom="10dp"  
             android:layout_toRightOf="@id/CashPayoutFee"  
             android:text="AccountCreditFee"  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="14sp" />  
           <TextView  
             android:id="@+id/AccountCreditFee"  
             android:layout_width="wrap_content"  
             android:layout_height="wrap_content"  
             android:layout_marginBottom="10dp"  
             android:layout_toRightOf="@id/AccountCreditFee1"  
             android:text=""  
             android:textColor="@color/colorPrimaryDark"  
             android:textSize="14sp" />  
         </RelativeLayout>  
         <View  
           android:layout_width="match_parent"  
           android:layout_height="1dp"  
           android:layout_marginBottom="10dp"  
           android:background="@color/colorPrimaryDark" />  
         <Button  
           android:id="@+id/Proceed"  
           android:layout_width="100dp"  
           android:layout_height="40dp"  
           android:layout_gravity="center"  
           android:text="Proceed"  
           android:textAllCaps="false"  
           android:textColor="@color/colorPrimaryDark" />  
       </LinearLayout>  
     </ScrollView>  
   </LinearLayout>  
 </android.support.constraint.ConstraintLayout>  



activity_searchable_spinner_drop_down_view.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
   xmlns:tools="http://schemas.android.com/tools"  
   android:layout_width="match_parent"  
   android:layout_height="match_parent"  
   android:orientation="vertical"  
   tools:context=".Activity.SearchableSpinnerDropDownViewActivity">  
   <EditText  
     android:id="@+id/inputSearch"  
     android:layout_width="match_parent"  
     android:layout_height="50dp"  
     android:layout_margin="5dp"  
     android:alpha="0.70"  
     android:drawableLeft="@android:drawable/ic_menu_search"  
     android:hint="Search"  
     android:padding="5dp" />  
   <ListView  
     android:id="@+id/listview"  
     android:layout_width="match_parent"  
     android:layout_height="match_parent"  
     android:layout_margin="5dp"  
     android:scrollbars="none" />  
 </LinearLayout>