Example usage for android.widget AdapterView getContext

List of usage examples for android.widget AdapterView getContext

Introduction

In this page you can find the example usage for android.widget AdapterView getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.gmail.emerssso.srbase.ListDailiesActivity.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.list_comments_activity);

    ActionBar actionBar = getActionBar();
    if (actionBar != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    ListView lv = this.getListView();
    lv.setDividerHeight(2);//from w w w  .j  ava 2s  . co m

    Bundle extras = getIntent().getExtras();

    srId = extras.getString(DailyTable.COLUMN_SR_ID);

    fillData();

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Intent i = new Intent(parent.getContext(), EditDailyActivity.class);
            Uri dayUri = Uri.parse(SRContentProvider.DAILY_CONTENT_URI + "/" + id);
            i.putExtra(SRContentProvider.DAILY_CONTENT_ITEM_TYPE, dayUri);
            startActivity(i);
        }
    });
}

From source file:com.gmail.emerssso.srbase.ListPartsActivity.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.list_parts_activity);

    ActionBar actionBar = getActionBar();
    if (actionBar != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    ListView lv = this.getListView();
    lv.setDividerHeight(2);/*  w w w .  j a  v a  2  s  .co m*/
    lv.setClickable(true);

    Bundle extras = getIntent().getExtras();

    srId = extras.getString(PartTable.COLUMN_SR_ID);

    if (srId == null)
        throw new RuntimeException("srId is null!");

    fillData();

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Intent i = new Intent(parent.getContext(), EditPartActivity.class);
            Uri partUri = Uri.parse(SRContentProvider.PART_CONTENT_URI + "/" + id);
            i.putExtra(SRContentProvider.PART_CONTENT_ITEM_TYPE, partUri);
            startActivity(i);
        }
    });
}

From source file:com.uf.togathor.adapters.GroupsListChatAdapter.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    Group group = (Group) arg0.getItemAtPosition(arg2);
    Context context = arg0.getContext();

    Intent intent;/*from ww w . j ava  2 s  . co m*/

    UsersManagement.setToGroup(group);
    UsersManagement.setToUser(null);

    if (group != null) {
        intent = new Intent(context, ChatGroupActivity.class);
        if (context.getResources().getBoolean(R.bool.isLollipop))
            (context).startActivity(intent);
        //ActivityCompat.startActivity(mActivity, intent, options.toBundle());
        else
            (context).startActivity(intent);
    }
}

From source file:tinygsn.gui.android.ActivityPullData.java

public void renderVSList() {
    spinner_vsName = (Spinner) findViewById(R.id.spinner_pull_vsname);
    List<String> list = new ArrayList<String>();

    for (String vs : vsNameList) {
        list.add(vs);/*from  w w w.j a  va2s  .c o  m*/
    }

    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner_vsName.setAdapter(dataAdapter);

    spinner_vsName.setOnItemSelectedListener(new OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            Toast.makeText(parent.getContext(),
                    "The VS \"" + parent.getItemAtPosition(pos).toString() + "\" is selected.",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
}

From source file:rs.pedjaapps.kerneltuner.ui.SDScannerActivity.java

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

    setContentView(R.layout.sd_analyzer_list);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    ListView sDListView = (ListView) findViewById(R.id.list);
    sDAdapter = new SDAdapter(this, R.layout.sd_list_row);
    sDListView.setAdapter(sDAdapter);/*www  .  j  ava  2s.com*/
    sDListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, final int pos, long arg3) {
            final SDScannerEntry entry = sDAdapter.getItem(pos);
            AlertDialog.Builder builder = new AlertDialog.Builder(arg0.getContext());
            builder.setTitle(entry.getFileName());
            builder.setMessage(getResources().getString(R.string.sd_alert_location) + " " + entry.getPath()
                    + "\n" + getResources().getString(R.string.sd_alert_size) + " " + entry.getHRsize());

            builder.setIcon(R.drawable.ic_menu_cc);

            if (new File(entry.getPath()).isDirectory()) {
                builder.setPositiveButton(getResources().getString(R.string.sd_alert_scan),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                path = entry.getPath();
                                new ScanSDCard().execute(path);
                            }
                        });
            }
            builder.setNegativeButton(getResources().getString(R.string.delete),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            new File(entry.getPath()).delete();
                            sDAdapter.remove(sDAdapter.getItem(pos));
                            sDAdapter.notifyDataSetChanged();
                        }
                    });

            AlertDialog alert = builder.create();
            alert.show();
        }

    });
    new ScanSDCard().execute(path);
}

From source file:org.bwgz.quotation.activity.QuotationsActivity.java

public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_keyword));

    final ListView drawerView = (ListView) findViewById(R.id.drawer_view);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.quotations_drawer), 1);
    drawerView.setAdapter(adapter);/*from   www.j a v a2  s .  c  o m*/
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            if (id == 0) {
                drawerLayout.closeDrawer(drawerView);
                startActivity(new Intent(parent.getContext(), HomeActivity.class));
            }
        }
    });

    return true;
}

From source file:com.anandbibek.notifyme.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (!access) {
        ProgressDialog pDialog = new ProgressDialog(this);
        pDialog.setMessage(getResources().getString(R.string.main_check_checking));
        pDialog.setMax(3000);//www.  j  av a 2  s  .  c  o m
        pDialog.setCancelable(false);
        pDialog.show();
        stuff = new CheckAccessibilityTask();
        stuff.execute(pDialog);
        return;
    }
    ListView mainFilterList = (ListView) this.findViewById(R.id.main_filter_list);
    String[] filterApps = new String[prefs.getNumberOfFilters() + 1];
    for (int i = 0; i < filterApps.length; i++) {
        if (i == prefs.getNumberOfFilters()) {
            filterApps[i] = "JOKER";
        } else {
            filterApps[i] = prefs.getFilterApp(i);
        }
    }
    ArrayAdapter<String> adapter = new MainFilterAdapter(this, filterApps);
    mainFilterList.setAdapter(adapter);
    mainFilterList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent editFilterIntent = new Intent(parent.getContext(), EditFilterActivity.class);
            if (position == prefs.getNumberOfFilters()) {
                editFilterIntent.setAction("new");
            } else {
                editFilterIntent.setAction("edit");
                editFilterIntent.putExtra("filter", position);
            }
            startActivity(editFilterIntent);
        }
    });
    mainFilterList.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final int filter = position;
            if (filter == prefs.getNumberOfFilters())
                return true;
            final View finalView = view;
            AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
            try {
                builder.setTitle(getResources().getString(R.string.main_remove_title1) + " "
                        + ((TextView) ((RelativeLayout) view).getChildAt(1)).getText() + " "
                        + getResources().getString(R.string.main_remove_title2));
                builder.setIcon(((ImageView) ((RelativeLayout) view).getChildAt(0)).getDrawable());
            } catch (Exception e) {

            }
            builder.setPositiveButton(R.string.main_remove_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    prefs.removeFilter(filter);
                    startActivity(new Intent(finalView.getContext(), MainActivity.class).setAction("redraw"));
                }
            });
            builder.setNegativeButton(R.string.main_remove_cancel, null);
            builder.show();
            return true;
        }
    });
}

From source file:org.bwgz.quotation.activity.SubjectsActivity.java

public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_subject));

    final ListView drawerView = (ListView) findViewById(R.id.drawer_view);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.subjects_drawer), 1);
    drawerView.setAdapter(adapter);/* w  w  w .  j a  v a  2s  . c o m*/
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            if (id == 0) {
                drawerLayout.closeDrawer(drawerView);
                startActivity(new Intent(parent.getContext(), HomeActivity.class));
            }
        }
    });

    return true;
}

From source file:com.lillicoder.demo.navigationdrawer.BaseNavigationActivity.java

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

    mDrawer = (DrawerLayout) findViewById(R.id.BaseNavigationActivity_drawer);
    mNavigationList = (ListView) findViewById(R.id.BaseNavigationActivity_navigationList);
    mContentContainer = (ViewGroup) findViewById(R.id.BaseNavigationActivity_contentContainer);

    final ActionBar actionBar = getSupportActionBar();
    //actionBar.setIcon(R.drawable.ic_launcher);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Configure action bar toggling and navigation drawer look & feel
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, R.drawable.ic_drawer_light, R.string.drawer_open,
            R.string.drawer_close) {//from   w w w  .j a  v a2  s . c  o  m
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);

            getSupportActionBar().setTitle(R.string.drawer_closed_title);
            supportInvalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);

            getSupportActionBar().setTitle(R.string.drawer_opened_title);
            supportInvalidateOptionsMenu();
        }
    };
    mDrawer.setDrawerListener(mDrawerToggle);
    mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // Configure navigation list
    List<NavigationItem> navigationItems = getNavigationItems();
    NavigationListAdapter adapter = new NavigationListAdapter(navigationItems);
    mNavigationList.setAdapter(adapter);
    mNavigationList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            NavigationItem item = (NavigationItem) parent.getItemAtPosition(position);
            Class<?> targetActivity = item.getTargetActivity();

            Context context = parent.getContext();

            Intent navigate = new Intent(context, targetActivity);
            if (position == 0) {
                // The top level navigation item should clear top
                navigate.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            }

            context.startActivity(navigate);
        }
    });
}

From source file:net.dahanne.android.google.client.GoogleActivity.java

private void showGoogleOptions() {
    Connection<Google> findPrimaryConnection = connectionRepository.findPrimaryConnection(Google.class);
    Log.e(TAG, findPrimaryConnection.getDisplayName());

    String[] options = { "Disconnect", "Profile" };
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            options);/*w  w  w .j ava2s. c om*/
    ListView listView = (ListView) this.findViewById(R.id.google_activity_options_list);
    listView.setAdapter(arrayAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parentView, View childView, int position, long id) {
            Intent intent;
            switch (position) {
            case 0:
                disconnect();
                showConnectOption();
                break;
            case 1:
                intent = new Intent();
                intent.setClass(parentView.getContext(), GoogleProfileActivity.class);
                startActivity(intent);
                break;
            default:
                break;
            }
        }
    });
}