Example usage for android.widget TextView setMovementMethod

List of usage examples for android.widget TextView setMovementMethod

Introduction

In this page you can find the example usage for android.widget TextView setMovementMethod.

Prototype

public final void setMovementMethod(MovementMethod movement) 

Source Link

Document

Sets the android.text.method.MovementMethod for handling arrow key movement for this TextView.

Usage

From source file:org.libreoffice.impressremote.fragment.ComputersFragment.java

private void showLearnMoreMessage() {
    TextView learnMoreView = (TextView) getView().findViewById(R.id.text_learn_more);
    Animation aFadeInAnimation = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);

    learnMoreView.setMovementMethod(LinkMovementMethod.getInstance());

    learnMoreView.startAnimation(aFadeInAnimation);
    learnMoreView.setVisibility(View.VISIBLE);
}

From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderAnyMemo.java

@Override
protected void fetchDatabase(final DownloadItem di) {
    final Thread downloadThread = new Thread() {
        @Override//from   www. j a  v a  2  s . co  m
        public void run() {
            String filename = di.getExtras("filename");
            try {
                downloadDatabase(di);
                filename = filename.replace(".zip", ".db");
                String sdpath = Environment.getExternalStorageDirectory().getAbsolutePath()
                        + getString(R.string.default_dir);
                final File dbFile = new File(sdpath + filename);
                mHandler.post(new Runnable() {
                    public void run() {
                        new AlertDialog.Builder(DownloaderAnyMemo.this)
                                .setTitle(R.string.downloader_download_success)
                                .setMessage(getString(R.string.downloader_download_success_message)
                                        + dbFile.toString())
                                .setPositiveButton(R.string.ok_text, null).create().show();
                    }
                });
            } catch (final Exception e) {
                mHandler.post(new Runnable() {
                    public void run() {
                        new AlertDialog.Builder(DownloaderAnyMemo.this)
                                .setTitle(R.string.downloader_download_fail)
                                .setMessage(getString(R.string.downloader_download_fail_message) + " "
                                        + e.toString())
                                .setPositiveButton(R.string.ok_text, null).create().show();
                    }
                });
            }
        }
    };
    View alertView = View.inflate(DownloaderAnyMemo.this, R.layout.link_alert, null);
    TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setText(
            Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription()));

    new AlertDialog.Builder(this).setView(alertView)
            .setTitle(getString(R.string.downloader_download_alert) + di.getExtras("filename"))
            .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface arg0, int arg1) {
                    downloadThread.start();
                }
            }).setNegativeButton(getString(R.string.no_text), null).show();

}

From source file:com.shearosario.tothepathandback.ClosestStationsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_closest_stations);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();/*from w ww  .jav a2s. c om*/
    context = this;
    activity = this;

    adView = (AdView) this.findViewById(R.id.adViewClosest);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build();
    // AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

    if (intent.hasExtra("Manual")) {
        double[] manual = intent.getDoubleArrayExtra("Manual");
        origin = new LatLng(manual[0], manual[1]);
    } else if (intent.hasExtra("Current")) {
        double[] current = intent.getDoubleArrayExtra("Current");
        origin = new LatLng(current[0], current[1]);
    }

    double[] entranceMeasures = intent.getDoubleArrayExtra("closestSortMeasures");
    ArrayList<Entrance> closestEntrances = intent.getParcelableArrayListExtra("closestEntrances");

    MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, R.layout.listitem, closestEntrances,
            entranceMeasures);
    //ListAdapter adapter = createListAdapter(allStationsSortDistance);
    ListView listview = (ListView) findViewById(R.id.ClosestStationsList);
    listview.setAdapter(adapter);
    //setListAdapter(adapter);

    final GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapview)).getMap();
    gMap.setMyLocationEnabled(false);
    gMap.addMarker(new MarkerOptions().title("Origin").position(origin));
    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(origin, 13));
    gMap.setBuildingsEnabled(false);
    gMap.getUiSettings().setZoomControlsEnabled(false);

    TextView textView = (TextView) findViewById(R.id.osm_directions);
    textView.setText(Html.fromHtml("Data provided by  OpenStreetMap contributors "
            + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    textView = (TextView) findViewById(R.id.directions_text);
    textView.setText(Html.fromHtml(
            "Directions, Nominatim Search Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Entrance item = (Entrance) parent.getItemAtPosition(position);

            gMap.clear();

            LatLngBounds bounds = new LatLngBounds.Builder().include(origin)
                    .include(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])).build();

            gMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));

            gMap.addMarker(new MarkerOptions().title("Origin").position(origin));

            String stationName = null;
            for (int i = 0; i < MainActivity.getAllStations().size(); i++) {
                if (item.getStopid().equalsIgnoreCase(MainActivity.getAllStations().get(i).getStopID())) {
                    stationName = MainActivity.getAllStations().get(i).getStopName();
                    break;
                }
            }

            gMap.addMarker(new MarkerOptions()
                    // .title(item.getStationName())
                    .title(stationName)
                    .position(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])));

            Button button = (Button) findViewById(R.id.button_destination);
            button.setEnabled(true);
            // button.setText("Select " + item.getStationName());
            button.setText("Select " + stationName);

            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    /*
                     * To check if the phone is currently using a network connection. 
                     * Listens to broadcasts when the the device is or is not connected to 
                     * a network
                     */
                    ConnectivityManager cm = (ConnectivityManager) context
                            .getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
                    if (!isConnected) {
                        Toast.makeText(context, "No network connection", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    new DisplayDirectionsIntent(context, activity, origin, item);
                }
            });
        }
    });
}

From source file:com.eyekabob.EventInfo.java

protected void loadEvent(JSONObject response) {
    try {//from  ww  w  .  j  a  v  a 2  s .c  om
        JSONObject jsonEvent = response.getJSONObject("event");

        artists = new ArrayList<String>();
        title = jsonEvent.getString("title");
        JSONObject jsonAllArtists = jsonEvent.getJSONObject("artists");
        headliner = jsonAllArtists.getString("headliner");
        Object artistObj = jsonAllArtists.get("artist");
        JSONArray jsonOpeners = new JSONArray();
        if (artistObj instanceof JSONArray) {
            jsonOpeners = (JSONArray) artistObj;
        }
        for (int i = 0; i < jsonOpeners.length(); i++) {
            String artistName = jsonOpeners.getString(i);
            if (!headliner.equals(artistName)) {
                artists.add(artistName);
            }
        }

        JSONObject jsonVenue = jsonEvent.getJSONObject("venue");
        venue = jsonVenue.optString("name");
        venueCity = jsonVenue.optString("city");
        venueStreet = jsonVenue.optString("street");
        venueUrl = jsonVenue.optString("url");
        startDate = EyekabobHelper.LastFM.toReadableDate(jsonEvent.getString("startDate"));
        JSONObject image = EyekabobHelper.LastFM.getLargestJSONImage(jsonEvent.getJSONArray("image"));
        imageUrl = image.getString("#text");
    } catch (JSONException e) {
        Log.e(getClass().getName(), "", e);
    }

    try {
        new EventImageTask().execute(new URL(imageUrl));
    } catch (MalformedURLException e) {
        Log.e(getClass().getName(), "Bad image URL [" + imageUrl + "]", e);
    }

    TextView titleView = (TextView) findViewById(R.id.infoMainHeader);
    titleView.setText(title);

    TextView headlinerView = (TextView) findViewById(R.id.infoSubHeaderOne);
    // TODO: I18N
    headlinerView.setText("Headlining: " + headliner);

    TextView dateTimeView = (TextView) findViewById(R.id.infoSubHeaderTwo);
    dateTimeView.setText(startDate);

    if (!startDate.equals("")) {
        Button tixButton = (Button) findViewById(R.id.infoTicketsButton);
        tixButton.setVisibility(View.VISIBLE);
    }

    LinearLayout artistsView = (LinearLayout) findViewById(R.id.infoFutureEventsContent);
    TextView alsoPerformingView = (TextView) findViewById(R.id.infoFutureEventsHeader);
    if (!artists.isEmpty()) {
        // TODO: I18N
        alsoPerformingView.setText("Also Performing:");
        for (String artist : artists) {
            TextView row = new TextView(this);
            row.setTextColor(Color.WHITE);
            row.setText(artist);
            row.setPadding(20, 0, 0, 20); // Left and bottom padding
            artistsView.addView(row);
        }
    }

    String venueDesc = "";
    TextView venueView = (TextView) findViewById(R.id.infoEventVenue);
    // TODO: Padding instead of whitespace
    venueDesc += "         " + venue;
    if (!venueCity.equals("") && !venueStreet.equals("")) {
        // TODO: I18N
        venueDesc += "\n         Address: " + venueStreet + "\n" + venueCity;
    }
    // TODO: Padding instead of whitespace
    venueDesc += "\n         " + startDate;

    TextView venueTitleView = (TextView) findViewById(R.id.infoBioHeader);
    if (!venue.equals("") || !venueCity.equals("") || !venueStreet.equals("")) {
        // TODO: I18N
        venueTitleView.setText("Venue Details:");
        View vView = findViewById(R.id.infoVenueDetails);
        vView.setVisibility(View.VISIBLE);
    } else {
        // TODO: I18N
        venueTitleView.setText("No Venue Details Available");
    }

    venueView.setVisibility(View.VISIBLE);
    venueView.setText(venueDesc);

    TextView websiteView = (TextView) findViewById(R.id.infoVenueWebsite);
    if (!venueUrl.equals("")) {
        // TODO: I18N
        websiteView.setVisibility(View.VISIBLE);
        websiteView.setText(Html.fromHtml("<a href=\"" + venueUrl + "\">More Information</a>"));
        websiteView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}

From source file:org.adblockplus.android.Preferences.java

private void showNotificationDialog(final String title, String message, String url) {
    url = TextUtils.htmlEncode(url);//from   ww w  .  j a  va2s . c  o m
    message = TextUtils.htmlEncode(message).replaceAll("&lt;a&gt;(.*?)&lt;/a&gt;",
            "<a href=\"" + url + "\">$1</a>");
    final TextView messageView = new TextView(this);
    messageView.setText(Html.fromHtml(message));
    messageView.setMovementMethod(LinkMovementMethod.getInstance());
    final int padding = 10;
    messageView.setPadding(padding, padding, padding, padding);
    new AlertDialog.Builder(this).setTitle(title).setView(messageView)
            .setIcon(android.R.drawable.ic_dialog_info).setPositiveButton(R.string.ok, null).create().show();
}

From source file:at.ac.uniklu.mobile.sportal.DashboardAboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AppInfo appInfo = Studentportal.getAppInfo();

    View aboutDialogView = getActivity().getLayoutInflater().inflate(R.layout.about_dialog, null);
    TextView aboutDialogVersionTextView = (TextView) aboutDialogView.findViewById(R.id.about_version_info);
    aboutDialogVersionTextView.setText(getString(R.string.app_version, appInfo.getVersionName()));
    TextView creditsTextView = (TextView) aboutDialogView.findViewById(R.id.credits);
    String creditsText = getString(R.string.credits_iconic) + " / " + getString(R.string.credits_tnp) + " / "
            + getString(R.string.credits_osm) + " / " + getString(R.string.credits_leaflet) + " / "
            + getString(R.string.credits_prevel) + " / " + getString(R.string.credits_gson) + " / "
            + getString(R.string.credits_vpi);
    creditsTextView.setText(Html.fromHtml(creditsText));
    creditsTextView.setMovementMethod(LinkMovementMethod.getInstance());

    aboutDialogView.findViewById(R.id.about_facebook).setOnClickListener(new View.OnClickListener() {
        @Override/*  w  ww.  j av a  2  s .  c  o m*/
        public void onClick(View v) {
            startActivity(Utils.getOpenFacebookIntent(getActivity()));
        }
    });

    aboutDialogView.findViewById(R.id.bugsense).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.bugsense.com")));
        }
    });

    return new AlertDialog.Builder(getActivity()).setView(aboutDialogView)
            .setNeutralButton(getString(R.string.close), null).create();
}

From source file:com.shearosario.tothepathandback.DisplayDirectionsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display_directions);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();//from w w  w . j a va2  s. c o m

    /*if(intent.hasExtra("origin"))
    {
       double[] temp = intent.getDoubleArrayExtra("origin");
       origin = new LatLng (temp[0], temp[1]);
    }
    if (intent.hasExtra("destination"))
    {
       double[] temp = intent.getDoubleArrayExtra("destination");
       destination = new LatLng (temp[0], temp[1]);
    }*/

    String linkCollection = null;
    String nodeCollection = null;
    String points = null;

    if (intent.hasExtra("GuidanceLinkCollection"))
        linkCollection = intent.getStringExtra("GuidanceLinkCollection");
    if (intent.hasExtra("GuidanceNodeCollection"))
        nodeCollection = intent.getStringExtra("GuidanceNodeCollection");
    if (intent.hasExtra("shapePoints"))
        points = intent.getStringExtra("shapePoints");

    gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.directionsView)).getMap();
    gMap.setMyLocationEnabled(false);
    gMap.setBuildingsEnabled(false);
    gMap.getUiSettings().setZoomControlsEnabled(false);

    TextView textView = (TextView) findViewById(R.id.osm_guidance);
    textView.setText(Html.fromHtml("Data provided by  OpenStreetMap contributors "
            + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    textView = (TextView) findViewById(R.id.guidance_text);
    textView.setText(
            Html.fromHtml("Guidance Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    PolylineOptions rectOptions = new PolylineOptions();
    markers = new ArrayList<Marker>();

    try {
        JSONArray jGuidanceLinkCollection = new JSONArray(linkCollection);
        JSONArray jGuidanceNodeCollection = new JSONArray(nodeCollection);
        JSONArray jShapePoints = new JSONArray(points);

        int lastIndex = 0;

        for (int i = 0; i < jGuidanceNodeCollection.length(); i++) {
            JSONObject nodeObject = jGuidanceNodeCollection.getJSONObject(i);
            JSONArray linkIds = nodeObject.getJSONArray("linkIds");

            int linkIndex = 0;
            if (linkIds.length() != 0)
                linkIndex = linkIds.getInt(0);
            else
                continue;

            JSONObject linkObject = jGuidanceLinkCollection.getJSONObject(linkIndex);
            int shapeIndex = linkObject.getInt("shapeIndex");

            // The index of a specific shape point is i/2, so multiply by 2 to get the beginning index in shapePoints
            // evens are lat and odds are lng
            double lat = jShapePoints.getDouble((shapeIndex * 2));
            double lng = jShapePoints.getDouble((shapeIndex * 2) + 1);

            lastIndex = ((shapeIndex * 2) + 1);

            if (i == 0) {
                Marker temp = gMap
                        .addMarker(new MarkerOptions().position(new LatLng(lat, lng)).title("Origin"));
                markers.add(temp);
            } else if (nodeObject.isNull("infoCollection") == false) {
                Marker temp = gMap.addMarker(new MarkerOptions().position(new LatLng(lat, lng))
                        .title(nodeObject.getJSONArray("infoCollection").getString(0)));
                markers.add(temp);
            }
        }

        for (int i = 0; i < lastIndex; i++) {
            double lat = jShapePoints.getDouble(i);
            i++;
            double lng = jShapePoints.getDouble(i);

            rectOptions.add(new LatLng(lat, lng));
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    gMap.addPolyline(rectOptions);

    markersIndex = 0;

    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(markersIndex).getPosition(), 17));
    markers.get(markersIndex).showInfoWindow();

    gMap.setOnMarkerClickListener(new OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker arg0) {
            if (arg0 != null) {
                for (int i = 0; i < markers.size(); i++) {
                    if (markers.get(i).equals(arg0)) {
                        markersIndex = i;
                        break;
                    }
                }

                if (markersIndex == 0) {
                    findViewById(R.id.button_nextStep).setEnabled(true);
                    findViewById(R.id.button_previousStep).setEnabled(false);
                } else if (markersIndex == (markers.size() - 1)) {
                    findViewById(R.id.button_nextStep).setEnabled(false);
                    findViewById(R.id.button_previousStep).setEnabled(true);
                } else {
                    findViewById(R.id.button_nextStep).setEnabled(true);
                    findViewById(R.id.button_previousStep).setEnabled(true);
                }

                gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(arg0.getPosition(), 17));

                arg0.showInfoWindow();

                return true;
            }

            return false;
        }
    });
}

From source file:com.blueoxfords.peacecorpstinder.activities.MainActivity.java

public void getLegalInfo(View v) {
    String photoId = v.getTag() + "";
    ImageRestClient.get().getInfoFromImageId(photoId, new Callback<ImageService.ImageInfoWrapper>() {
        @Override/*from  w  ww . j  a  v  a  2 s  .  com*/
        public void success(ImageService.ImageInfoWrapper imageInfoWrapper, Response response) {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.activity);

            ScrollView wrapper = new ScrollView(MainActivity.activity);
            LinearLayout infoLayout = new LinearLayout(MainActivity.activity);
            infoLayout.setOrientation(LinearLayout.VERTICAL);
            infoLayout.setPadding(35, 35, 35, 35);

            TextView imageOwner = new TextView(MainActivity.activity);
            imageOwner.setText(Html.fromHtml("<b>Image By: </b>" + imageInfoWrapper.photo.owner.username));
            if (imageInfoWrapper.photo.owner.realname.length() > 0) {
                imageOwner.setText(imageOwner.getText() + " (" + imageInfoWrapper.photo.owner.realname + ")");
            }
            infoLayout.addView(imageOwner);

            if (getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license)).length() > 0) {
                TextView licenseLink = new TextView(MainActivity.activity);
                licenseLink.setText(Html
                        .fromHtml("<a href=\"" + getLicenseUrl(Integer.parseInt(imageInfoWrapper.photo.license))
                                + "\"><b>Licensing</b></a>"));
                licenseLink.setMovementMethod(LinkMovementMethod.getInstance());
                infoLayout.addView(licenseLink);
            }

            if (imageInfoWrapper.photo.urls.url.size() > 0) {
                TextView imageLink = new TextView(MainActivity.activity);
                imageLink.setText(Html.fromHtml("<a href=\"" + imageInfoWrapper.photo.urls.url.get(0)._content
                        + "\"><b>Image Link</b></a>"));
                imageLink.setMovementMethod(LinkMovementMethod.getInstance());
                infoLayout.addView(imageLink);
            }

            if (imageInfoWrapper.photo.title._content.length() > 0) {
                TextView photoTitle = new TextView(MainActivity.activity);
                photoTitle
                        .setText(Html.fromHtml("<b>Image Title: </b>" + imageInfoWrapper.photo.title._content));
                infoLayout.addView(photoTitle);
            }

            if (imageInfoWrapper.photo.description._content.length() > 0) {
                TextView description = new TextView(MainActivity.activity);
                description.setText(Html
                        .fromHtml("<b>Image Description: </b>" + imageInfoWrapper.photo.description._content));
                infoLayout.addView(description);
            }

            TextView contact = new TextView(MainActivity.activity);
            contact.setText(
                    Html.fromHtml("<br><i>To remove this photo, please email pcorpsconnect@gmail.com</i>"));
            infoLayout.addView(contact);

            wrapper.addView(infoLayout);

            builder.setTitle("Photo Information");
            builder.setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                }
            });
            builder.setView(wrapper);
            builder.create().show();
        }

        @Override
        public void failure(RetrofitError error) {
            Log.i("testing", "could not retrieve legal/attribution info");
        }
    });
}

From source file:com.parse.f8.view.SignInActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_login);

    //////////////////////////
    //       try {
    //              PackageInfo info = getPackageManager().getPackageInfo("com.parse.f8", PackageManager.GET_SIGNATURES);
    //              for (android.content.pm.Signature signature : info.signatures) {
    //                  MessageDigest md = MessageDigest.getInstance("SHA");
    //                  md.update(signature.toByteArray());
    //                  String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT);
    //                  Log.d("MY KEY HASH:", sign);
    //                //  Toast.makeText(getApplicationContext(),sign,     Toast.LENGTH_LONG).show();
    //              }
    //      } catch (NameNotFoundException e1) {
    //      } catch (NoSuchAlgorithmException e1) {
    //      }//from   w  w w.ja  v a2s. c  o  m
    //////////////////////////

    TextView tos = (TextView) findViewById(R.id.tos);
    tos.setMovementMethod(LinkMovementMethod.getInstance());

    Button loginButton = (Button) findViewById(R.id.loginButton);
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onLoginButtonClicked();
        }
    });

}

From source file:com.limewoodmedia.nsdroid.fragments.EmbassiesFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.embassies, null, false);
    list = (ListView) root.findViewById(R.id.embassies_list);

    embassies = new ArrayList<Embassy>();
    listAdapter = new ArrayAdapter<Embassy>(context, 0, embassies) {
        @Override/*  w  w w. j  a  v  a  2 s. c  o  m*/
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView name, status;
            Embassy embassy;

            if (convertView == null) {
                view = inflater.inflate(R.layout.embassy, null);
                name = (TextView) view.findViewById(R.id.embassy_name);
                name.setMovementMethod(LinkMovementMethod.getInstance());
                status = (TextView) view.findViewById(R.id.embassy_status);
            } else {
                view = convertView;
                name = (TextView) view.findViewById(R.id.embassy_name);
                status = (TextView) view.findViewById(R.id.embassy_status);
            }
            embassy = getItem(position);

            // Region
            String eName = TagParser.idToName(embassy.region);
            name.setText(Html.fromHtml(eName));

            // Status
            String str = null;
            Resources res = getResources();
            int background = R.drawable.embassy_established;
            switch (embassy.status) {
            case INVITED:
                str = res.getString(R.string.embassy_invited);
                background = R.drawable.embassy_invited;
                break;
            case PENDING:
                str = res.getString(R.string.embassy_pending);
                background = R.drawable.embassy_pending;
                break;
            case REQUESTED:
                str = res.getString(R.string.embassy_requested);
                background = R.drawable.embassy_requested;
                break;
            case REJECTED:
                str = res.getString(R.string.embassy_rejected);
                background = R.drawable.embassy_denied;
                break;
            case CLOSING:
                str = res.getString(R.string.embassy_closing);
                background = R.drawable.embassy_closing;
                break;
            case ESTABLISHED:
                break;
            }
            status.setText(str);
            view.setBackgroundResource(background);

            view.setTag(embassy);
            view.setOnClickListener(EmbassiesFragment.this);
            name.setOnClickListener(EmbassiesFragment.this);
            status.setOnClickListener(EmbassiesFragment.this);

            return view;
        }
    };
    list.setAdapter(listAdapter);

    ((Spinner) root.findViewById(R.id.embassies_filter)).setOnItemSelectedListener(this);

    return root;
}