Example usage for android.widget AdapterView.OnItemClickListener AdapterView.OnItemClickListener

List of usage examples for android.widget AdapterView.OnItemClickListener AdapterView.OnItemClickListener

Introduction

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

Prototype

AdapterView.OnItemClickListener

Source Link

Usage

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);/*from   www. j  a va2 s.  c  om*/
    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.thaliproject.nativetest.app.fragments.PeerListFragment.java

public synchronized void setListener(Listener listener) {
    mListener = listener;/*  w ww.  ja v a 2 s . c  om*/

    if (mListener != null && mListView != null) {
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int index, long l) {
                mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index);
                Log.i(TAG, "onItemClick: " + mSelectedPeerProperties.toString());

                if (mListener != null) {
                    mListener.onPeerSelected(mSelectedPeerProperties);
                }
            }
        });

        mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> adapterView, View view, int index, long l) {
                mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index);
                Log.i(TAG, "onItemLongClick: " + mSelectedPeerProperties.toString());

                if (mListener != null) {
                    mListener.onPeerSelected(mSelectedPeerProperties);
                }

                return false; // Let the event propagate
            }
        });

        mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int index, long l) {
                mSelectedPeerProperties = (PeerProperties) mListView.getItemAtPosition(index);
                Log.i(TAG, "onItemSelected: " + mSelectedPeerProperties.toString());

                if (mListener != null) {
                    mListener.onPeerSelected(mSelectedPeerProperties);
                }
            }

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

From source file:com.sakisds.icymonitor.activities.ConnectionActivity.java

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

    setContentView(R.layout.activity_connection);
    mSettings = getSharedPreferences(MainViewActivity.SHAREDPREFS_FILE, 0);

    refreshListAdapter();//from w  w  w . java 2  s.  co m

    ListView listView = getListView();

    listView.setLongClickable(true);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new MultipleChoiceListener());

    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position, long id) {
            String url = "http://" + ((TextView) v.findViewById(R.id.text_address)).getText().toString();
            connect(url);
        }
    });

    // Http Client
    mClient.setMaxRetriesAndTimeout(2, 2000);

    // Setup GCM
    context = getApplicationContext();
    regid = getRegistrationId(context);

    if (regid.length() == 0) {
        registerBackground();
    }
    gcm = GoogleCloudMessaging.getInstance(this);
}

From source file:com.f16gaming.pathofexilestatistics.MainActivity.java

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

    setContentView(R.layout.main);/* ww  w  .  j  a va2 s .  co m*/

    LayoutInflater inflater = getLayoutInflater();

    poeEntries = new ArrayList<PoeEntry>();

    statsView = (ListView) findViewById(R.id.statsView);

    listFooter = inflater.inflate(R.layout.list_footer, null);

    statsView.addFooterView(listFooter);

    statsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onStatsViewClick(position);
        }
    });

    AlertDialog.Builder refreshWarningBuilder = new AlertDialog.Builder(this);
    refreshWarningBuilder.setTitle(R.string.refresh_warning).setMessage(R.string.refresh_warning_message)
            .setCancelable(true)
            .setNegativeButton(R.string.refresh_warning_reset, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    resetList();
                }
            }).setPositiveButton(R.string.refresh_warning_confirm, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    refreshList(true);
                }
            });

    refreshWarningDialog = refreshWarningBuilder.create();

    AlertDialog.Builder rankGoBuilder = new AlertDialog.Builder(this);
    View view = inflater.inflate(R.layout.rank_go_dialog, null);

    numberPicker = (net.simonvt.numberpicker.NumberPicker) view.findViewById(R.id.number_picker);
    numberPicker.setMinValue(1);
    numberPicker.setMaxValue(max);

    rankGoBuilder.setTitle(R.string.rank_go_dialog_title).setView(view).setCancelable(true)
            .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    // Do nothing
                }
            }).setPositiveButton(R.string.go, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    int rawOffset = numberPicker.getValue() - 1;
                    if (rawOffset >= limit * offset && rawOffset <= limit + limit * offset)
                        showToast(String.format(getString(R.string.toast_rank_showing), rawOffset + 1));
                    else
                        updateList(showHardcore, false, rawOffset);
                }
            });

    rankGoDialog = rankGoBuilder.create();

    resetList();
}

From source file:com.slidinglayersample.MainActivity.java

public void initState() {

    mListViewCompanies = (ListView) findViewById(R.id.listViewCompany);

    for (int i = 0; i < 10; i++) {
        Company c = new Company();
        c.setName("Company Name");
        mCompanyArrayList.add(c);/*  w ww  . j a v  a  2s  .  c  o  m*/
    }

    mCompanyAdapter = new CompanyAdapter(mCompanyArrayList);
    mListViewCompanies.setAdapter(mCompanyAdapter);

    mListViewCompanies.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Intent i = new Intent(MainActivity.this, CompanyProfileActivity.class);
            Bundle bundle = new Bundle();
            bundle.putSerializable(CompanyProfileActivity.KEY_COMPANY, mCompanyAdapter.getItem(position));
            i.putExtras(bundle);

            startActivity(i);

            new Thread(new Runnable() {
                @Override
                public void run() {
                    // Perform long-running task here
                    // (like audio buffering).
                    // you may want to update some progress
                    // bar every second, so use handler:
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            // make operation on UI - on example
                            // on progress bar.
                            mDrawerLayout.closeDrawer(mDrawerLinearLayout);
                        }
                    });
                }
            }).start();

        }
    });

}

From source file:com.vuze.android.remote.activity.DrawerActivity.java

@SuppressLint("NewApi")
public void onCreate_setupDrawer() {
    setupProfileSpinner();//from   ww  w .j a va  2s. c  om

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            DrawerActivity.this.onDrawerClosed(view);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            DrawerActivity.this.onDrawerOpened(view);
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerView = findViewById(R.id.drawer_view);
    ListView mDrawerList = (ListView) findViewById(R.id.drawer_listview);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mDrawerLayout.setElevation(30);
    }

    Resources res = getResources();
    // Set the adapter for the list view
    mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, R.id.title,
            new CharSequence[] { res.getText(R.string.drawer_torrents), res.getText(R.string.drawer_rcm),
                    res.getText(R.string.drawer_logout), }));
    // Set the list's click listener
    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mDrawerLayout.closeDrawer(mDrawerView);
            switch (position) {
            case 0: {
                Intent intent = new Intent(Intent.ACTION_VIEW, null, DrawerActivity.this,
                        TorrentViewActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.putExtra(SessionInfoManager.BUNDLE_KEY, getSessionInfo().getRemoteProfile().getID());
                startActivity(intent);
                break;
            }

            case 1: {
                Intent intent = new Intent(Intent.ACTION_VIEW, null, DrawerActivity.this, RcmActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.putExtra(SessionInfoManager.BUNDLE_KEY, getSessionInfo().getRemoteProfile().getID());
                startActivity(intent);
                break;
            }

            case 2: {
                RemoteUtils.openRemoteList(DrawerActivity.this);
                SessionInfoManager.removeSessionInfo(getSessionInfo().getRemoteProfile().getID());
                finish();
                break;
            }
            }
        }
    });
}

From source file:com.javielinux.fragments.SearchGeoFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = View.inflate(getActivity(), R.layout.search_geo_fragment, null);

    useGeo = (CheckBox) view.findViewById(R.id.cb_use_geo);
    typeGeo = (RadioGroup) view.findViewById(R.id.rg_type_geo);
    typeGeoGPS = (RadioButton) view.findViewById(R.id.rb_use_gps);
    typeGeoMap = (RadioButton) view.findViewById(R.id.rb_use_map);
    typeDistance = (RadioGroup) view.findViewById(R.id.rg_type_distance);
    typeDistanceMiles = (RadioButton) view.findViewById(R.id.rb_distance_miles);
    typeDistanceKM = (RadioButton) view.findViewById(R.id.rb_distance_km);

    llLocation = (LinearLayout) view.findViewById(R.id.ll_location);
    llMap = (LinearLayout) view.findViewById(R.id.ll_map);
    llDistance = (LinearLayout) view.findViewById(R.id.ll_distance);

    place = (AutoCompleteTextView) view.findViewById(R.id.et_place);

    address_list = new ArrayList<Address>();
    address_adapter = new AddressAdapter(getActivity(), address_list);
    place.setAdapter(address_adapter);/*  w ww.  j  a  va 2s.c  o m*/

    place.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Address address = address_adapter.getAddressItem(i);

            if (address != null) {
                latitude.setText(String.valueOf(address.getLatitude()));
                longitude.setText(String.valueOf(address.getLongitude()));
            }
        }
    });

    latitude = (EditText) view.findViewById(R.id.et_latitude);
    longitude = (EditText) view.findViewById(R.id.et_longitude);
    distance = (SeekBar) view.findViewById(R.id.sb_distance);
    distanceTxt = (TextView) view.findViewById(R.id.distance);

    distance.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
            changeTextDistance(arg1);
        }

        @Override
        public void onStartTrackingTouch(SeekBar arg0) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar arg0) {
        }
    });

    useGeo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showFields();
            } else {
                hideFields();
            }
        }
    });

    typeGeoGPS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                hideFieldsMap();
            }
        }
    });

    typeGeoMap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                showFieldsMap();
            }
        }
    });

    typeDistanceMiles.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reloadTextDistance();
        }
    });

    typeDistanceKM.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reloadTextDistance();
        }
    });

    place.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String currentText = place.getText().toString();

            if (currentText.length() >= 3)
                APITweetTopics.execute(getActivity(), getLoaderManager(), SearchGeoFragment.this,
                        new GetGeolocationAddressRequest(getActivity(), currentText, false));
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void afterTextChanged(Editable editable) {
        }
    });

    populateFields();

    return view;
}

From source file:ca.ippetad.geerweekapp.view.MainActivity.java

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

    /** View **//*from  ww  w.j  a va 2  s .c o  m*/
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    /** FRAGMENTS **/
    _frame = (FrameLayout) findViewById(R.id.container);

    _feed = new FeedFragment();
    _events = new EventsFragment();
    _kidnap = new KidnapFragment();
    _godiva = new GodivaFragment();
    _misc = new MiscFragment();

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, _feed).commit();
    }

    /** SLIDING MENU **/
    _slide = new SlidingMenu(this);
    _slide.setMode(SlidingMenu.LEFT);
    _slide.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    _slide.setBehindOffset(250);
    _slide.setFadeDegree(.9f);
    _slide.setBackgroundColor(Color.parseColor("#444444"));
    _slide.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    _slide.setMenu(R.layout.layout_menu);

    _slide.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
        @Override
        public void onOpened() {
            MENU_STATE = HIDDEN;
            invalidateOptionsMenu();
        }
    });
    _slide.setOnClosedListener(new SlidingMenu.OnClosedListener() {
        @Override
        public void onClosed() {
            MENU_STATE = VISIBLE;
            invalidateOptionsMenu();
        }
    });

    CustomTopBar bar = (CustomTopBar) findViewById(R.id.topbar);
    bar.setOnDrawerClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            _slide.toggle();
        }
    });

    ListView sliderList = (ListView) _slide.getRootView().findViewById(R.id.listview);
    CustomArrayAdapter slider_adapter = new CustomArrayAdapter(this, android.R.layout.simple_list_item_1,
            new String[] { "Home", "Events", "Kidnapping", "Godiva", "Misc" });
    sliderList.setAdapter(slider_adapter);
    sliderList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            switch (i) {
            case 0:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _feed)
                        .addToBackStack(null).commit();
                break;
            case 1:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _events)
                        .addToBackStack(null).commit();
                break;
            case 2:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _kidnap)
                        .addToBackStack(null).commit();
                break;
            case 3:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _godiva)
                        .addToBackStack(null).commit();
                break;
            case 4:
                getSupportFragmentManager().beginTransaction().replace(R.id.container, _misc)
                        .addToBackStack(null).commit();
                break;
            }
            _slide.toggle();
        }
    });

}

From source file:io.jari.geenstijl.Blog.java

public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.blog);/*  ww w . ja  v  a  2 s .  c  o  m*/

    super.onCreate(savedInstanceState);

    actionBar = getSupportActionBar();
    final PullToRefreshLayout mPullToRefreshLayout = (PullToRefreshLayout) findViewById(R.id.ptr_layout);

    View drawer = findViewById(R.id.left_drawer);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);
            enableImmersive(false, drawerLayout);
        }
    };
    drawerLayout.setDrawerListener(drawerToggle);

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    if (Build.VERSION.SDK_INT >= 19) {
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        drawer.setPadding(drawer.getPaddingLeft(), drawer.getPaddingTop() + config.getPixelInsetTop(true),
                drawer.getPaddingRight(), drawer.getPaddingBottom());
    }
    ListView siteSwitch = (ListView) drawer.findViewById(R.id.site_switcher);
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.drawer_list_item,
            R.id.wrap_text, new String[] { "GeenStijl.nl", "GeenStijl.tv" });
    siteSwitch.setAdapter(arrayAdapter);
    siteSwitch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                API.setDomain("www.geenstijl.nl", Blog.this);
                break;
            case 1:
                API.setDomain("www.geenstijl.tv", Blog.this);
                break;
            }

            forceNoImmersive = true;
            enableImmersive(false, drawerLayout);
            drawerLayout.closeDrawers();
            mPullToRefreshLayout.setRefreshing(true);
            new Thread(new Runnable() {
                public void run() {
                    forceNoImmersive = true;
                    try {
                        final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext());
                        initUI(artikelen, false);
                        runOnUiThread(new Runnable() {
                            public void run() {
                                mPullToRefreshLayout.setRefreshComplete();
                                forceNoImmersive = false;
                            }
                        });
                    } catch (final Exception e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            public void run() {
                                forceNoImmersive = false;
                                mPullToRefreshLayout.setRefreshComplete();
                                Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout"
                                        : e.getLocalizedMessage(), Style.ALERT).show();
                            }
                        });
                    }
                }
            }).start();
        }
    });

    ListView applist = (ListView) findViewById(R.id.applist);
    applist.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.wrap_text, new String[] {
            getResources().getString(R.string.options), getResources().getString(R.string.about) }));
    applist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                startActivity(new Intent(Intent.ACTION_VIEW, null, Blog.this, Settings.class));
                break;
            case 1:
                new AboutDialog(Blog.this).show(getSupportFragmentManager(), "AbtDlg");
                break;
            }
            drawerLayout.closeDrawers();
        }
    });

    reloadDrawer();

    // Now setup the PullToRefreshLayout
    ActionBarPullToRefresh.from(this).allChildrenArePullable().listener(new OnRefreshListener() {
        public void onRefreshStarted(View view) {
            new Thread(new Runnable() {
                public void run() {
                    forceNoImmersive = true;
                    try {
                        final Artikel[] artikelen = API.getArticles(true, false, getApplicationContext());
                        initUI(artikelen, false);
                    } catch (final Exception e) {
                        e.printStackTrace();
                        runOnUiThread(new Runnable() {
                            public void run() {
                                forceNoImmersive = false;
                                mPullToRefreshLayout.setRefreshComplete();
                                Crouton.makeText(Blog.this, e.getLocalizedMessage() == null ? "Onbekende fout"
                                        : e.getLocalizedMessage(), Style.ALERT).show();
                            }
                        });
                    }
                }
            }).start();
        }
    }).setup(mPullToRefreshLayout);

    new Thread(new Runnable() {
        public void run() {
            try {
                final Artikel[] artikelen = API.getArticles(false, false, getApplicationContext());
                initUI(artikelen, true);
            } catch (final Exception e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        errorMessage = e.getMessage();
                        switchState(STATE_ERROR);
                    }
                });
            }
        }
    }).start();

    //do changelog stuff
    SharedPreferences sPref = this.getSharedPreferences("geenstijl", 0);
    int version = 0;
    try {
        version = this.getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
    } catch (PackageManager.NameNotFoundException ignored) {
    }

    //is changelog already read
    if (!sPref.getBoolean("changelog-" + version, false)) {
        //set changelog to read
        sPref.edit().putBoolean("changelog-" + version, true).commit();

        //show dialog
        LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        ChangeLogListView chgList = (ChangeLogListView) layoutInflater.inflate(R.layout.changelog, null);

        new AlertDialog.Builder(this).setTitle(R.string.changelog_title).setView(chgList)
                .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }
                }).create().show();
    }

}

From source file:com.facebook.GraphObjectListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(layout, container, false);

    listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override// w  w w. j a  va2s .c o m
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            onListItemClick((ListView) parent, v, position);
        }
    });
    listView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            // We don't actually do anything differently on long-clicks, but setting the listener
            // enables the selector transition that we have for visual consistency with the
            // Facebook app's pickers.
            return false;
        }
    });
    listView.setOnScrollListener(onScrollListener);
    listView.setAdapter(adapter);

    activityCircle = (ProgressBar) view.findViewById(R.id.com_facebook_picker_activity_circle);

    return view;
}