[Android] Set custom layout for network dropdown menu

Geoffrey Métais git at videolan.org
Wed May 10 15:05:05 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr 18 13:27:00 2017 +0200| [375060582173cdc665c3fcfd5688f8202fda6680] | committer: Geoffrey Métais

Set custom layout for network dropdown menu

> https://code.videolan.org/videolan/vlc-android/commit/375060582173cdc665c3fcfd5688f8202fda6680
---

 vlc-android/res/layout/dropdown_item.xml                           | 7 +++++++
 .../src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java      | 7 ++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/vlc-android/res/layout/dropdown_item.xml b/vlc-android/res/layout/dropdown_item.xml
new file mode 100644
index 0000000..f12252d
--- /dev/null
+++ b/vlc-android/res/layout/dropdown_item.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:minWidth="72dp"
+    android:minHeight="48dp"
+    android:gravity="center" />
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
index 3974bc2..7dc4c73 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
@@ -16,15 +16,16 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.Spinner;
 import android.widget.TextView;
 
+import org.videolan.medialibrary.media.MediaWrapper;
 import org.videolan.vlc.R;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.media.MediaDatabase;
-import org.videolan.medialibrary.media.MediaWrapper;
 
 public class NetworkServerDialog extends DialogFragment implements AdapterView.OnItemSelectedListener, TextWatcher, View.OnClickListener {
 
@@ -113,6 +114,10 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
+
+        ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<>(view.getContext(), R.layout.dropdown_item, getResources().getStringArray(R.array.server_protocols));
+        mSpinnerProtocol.setAdapter(spinnerArrayAdapter);
+
         if (mUri != null) {
             mIgnoreFirstSpinnerCb = true;
             mEditAddress.setText(mUri.getHost());



More information about the Android mailing list