findViewById为EditText返回null,将值从一个类传递到另一个类

时间:2015-08-12 07:49:55

标签: android

这是我的代码。

public void HandleSearchButtonValue(int START_INDEX,int places,String featurea)
    {
        try
        {
            EditText locationEdit=(EditText)findViewById(places);
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(locationEdit.getWindowToken(), 0);
            String locationAddress =locationEdit.getText().toString();
        /*try {
            Geocoder geocoder;
            List<Address> addresses;
            geocoder = new Geocoder(this, Locale.getDefault());
            addresses = geocoder.getFromLocation(lat, longt, 1);
            addressline = addresses.get(0).getAddressLine(0);

        } catch (IOException e) {
            return;
        }
        String locationAddress =addressline;*/

            if (locationAddress.equals("")){
                removePoint(START_INDEX);
                map.invalidate();
                return;
            }
            Toast.makeText(this, "Searching:\n"+locationAddress, Toast.LENGTH_LONG).show();
            AutoCompleteOnPreferences.storePreference(this, locationAddress, SHARED_PREFS_APPKEY, PREF_LOCATIONS_KEY);
            new GeocodingTask().execute(locationAddress, START_INDEX);
            String feature = featurea;

            mPoiMarkers = new RadiusMarkerClusterer(this);
            Drawable clusterIconD = getResources().getDrawable(R.drawable.marker_atm);
            Bitmap clusterIcon = ((BitmapDrawable) clusterIconD).getBitmap();
            mPoiMarkers.setIcon(clusterIcon);
            mPoiMarkers.mAnchorV = Marker.ANCHOR_BOTTOM;
            mPoiMarkers.mTextAnchorU = 0.70f;
            mPoiMarkers.mTextAnchorV = 0.27f;
            mPoiMarkers.getTextPaint().setTextSize(12.0f);
            map.getOverlays().add(mPoiMarkers);
            updateUIWithPOI(mPOIs, "");

            if (!feature.equals(""))
                Toast.makeText(this, "Searching:\n" + feature, Toast.LENGTH_LONG).show();
            getPOIAsync(feature);
        }
        catch (Exception e) {
          e.getMessage();
        }
    }

0 个答案:

没有答案