Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "interactions":
- [
- {
- "MDT1": "ACIDE ACETOHYDROXAMIQUE",
- "MDT2": "FER",
- "CI": "",
- "AD": "",
- "PE": "",
- "PC": "A prendre en compte Diminution de l'absorption digestive de ces deux medicaments par chelation du fer..."
- },
- {
- "MDT1": "ACETAZOLAMIDE",
- "MDT2": "ACIDE ACETYLSALICYLIQUE",
- "CI": "",
- "AD": "Association DECONSEILLEE Majoration des effets indesirables.....",
- "PE": "",
- "PC": ""
- },
- {
- "MDT1": "ACETAZOLAMIDE",
- "MDT2": "CARBAMAZEPINE",
- "CI": "",
- "AD": "",
- "PE": "Precaution d'emploi Surveillance clinique........",
- "PC": ""
- },
- {
- "MDT1": "CARBAMAZEPINE",
- "MDT2": "OLANZAPINE",
- "CI": "",
- "AD": "",
- "PE": "Precaution d'emploi Surveillance clinique, et si besoin, adaptation posologique de l'olanzapine. Risque de diminution des concentrations plasmatiques de l'olanzapine et de son efficacite therapeutique, par augmentation de son metabolisme hepatique par la carbamazepine.",
- "PC": ""
- }
- ]
- }
- public SearchableSpinner mySpinner;
- private SearchableSpinner mySpinner1;
- public ArrayList<Interactions> world = new ArrayList<>();
- public final ArrayList<String> mStrings = new ArrayList<>();
- public final ArrayList<String> m2Strings = new ArrayList<>();
- public class DownloadJSON extends AsyncTask<Void, Void, Void> {
- @Override
- protected Void doInBackground(Void... params) {
- // Locate the Interactions Class
- jsonobject = JSONfunctions
- .getJSONfromURL("https://rabah.000webhostapp.com/data.txt");
- try {
- // Locate the NodeList name
- jsonarray = jsonobject.getJSONArray("interactions");
- for (int j = 0; j < jsonarray.length(); j++ ) {
- jsonobject = jsonarray.getJSONObject(j);
- Interactions worldpop = new Interactions();
- worldpop.setMDT1(jsonobject.optString("MDT1"));
- worldpop.setMDT2(jsonobject.optString("MDT2"));
- worldpop.setPE(jsonobject.optString("PE"));
- worldpop.setCI(jsonobject.optString("CI"));
- worldpop.setAD(jsonobject.optString("AD"));
- worldpop.setPC(jsonobject.optString("PC"));
- world.add(worldpop);
- // Populate spinner with mdts names
- mStrings.add(jsonobject.optString("MDT1"));
- m2Strings.add(jsonobject.optString("MDT2"));
- }
- } catch (Exception e) {
- Log.e("Error", e.getMessage());
- e.printStackTrace();
- }
- return null;
- }
- @Override
- protected void onPostExecute(Void args) {
- // Spinner adapter
- mySpinner.setAdapter(new SimpleListAdapter(MainActivity.this,
- android.R.layout.simple_spinner_dropdown_item,
- mStrings));
- mySpinner1.setAdapter(new SimpleListAdapter(MainActivity.this,
- android.R.layout.simple_spinner_dropdown_item,
- m2Strings));
- }}
- private OnItemSelectedListener mOnItemSelectedListener = new OnItemSelectedListener() {
- @Override
- public void onItemSelected(View view, int position, long id) {
- TextView txtMDT1 = (TextView) findViewById(R.id.MDT1);
- txtMDT1.setText("MDT1 : " + world.get(position).getMDT1());
- TextView txtMDT2 = (TextView) findViewById(R.id.MDT2);
- txtMDT2.setText("MDT2 : " + world.get(position).getMDT2());
- String PE = world.get(position).getPE();
- String PC = world.get(position).getPC();
- String CI = world.get(position).getCI();
- String AD = world.get(position).getAD();
- if (PE!="")
- {
- TextView txtPE = (TextView) findViewById(R.id.t);
- txtPE.setText("PE : " + world.get(position).getPE());
- }else if (PC!="") {
- TextView txtPc = (TextView) findViewById(R.id.t);
- txtPc.setText("Pc : " + world.get(position).getPC());
- }
- }
- @Override
- public void onNothingSelected() {
- Toast.makeText(MainActivity.this, "Nothing Selected", Toast.LENGTH_SHORT).show();
- }
- };
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/content_main"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
- tools:context="gr.escsoft.michaelprimez.searchablespinnerexamples.MainActivity"
- tools:showIn="@layout/activity_main">
- <gr.escsoft.michaelprimez.searchablespinner.SearchableSpinner
- android:id="@+id/mySpinner"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="24dp"
- android:layout_marginLeft="24dp"
- android:layout_marginRight="24dp"
- android:layout_marginStart="24dp"
- android:layout_marginEnd="24dp"
- app:RevealEmptyText="Touch to select"
- android:gravity="center_horizontal"
- app:ShowBorders="true"
- app:BordersSize="1dp"
- app:BoarderColor="@color/colorPrimary"
- app:SpinnerExpandHeight="250dp"/>
- <gr.escsoft.michaelprimez.searchablespinner.SearchableSpinner
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:id="@+id/mySpinner1"
- app:SpinnerExpandHeight="0dp"
- app:BoarderColor="@android:color/holo_blue_light"
- app:BordersSize="1dp" app:ShowBorders="true"
- android:gravity="center_horizontal"
- android:layout_marginEnd="24dp"
- android:layout_marginStart="24dp"
- android:layout_marginRight="24dp"
- android:layout_marginLeft="24dp"
- android:layout_marginTop="24dp"
- app:RevealEmptyText="Touch to select"
- app:SearchViewBackgroundColor="@android:color/holo_blue_light"
- app:RevealViewBackgroundColor="@android:color/holo_blue_light"
- app:DoneSearchTintColor="@android:color/white"
- app:StartSearchTintColor="@android:color/white"
- android:layout_below="@+id/mySpinner"/>
- <TextView
- android:id="@+id/MDT1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/mySpinner1" />
- <TextView
- android:id="@+id/MDT2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/MDT1" />
- <TextView
- android:id="@+id/t"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/MDT2" />
- </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement