Example usage for android.widget AdapterView getItemAtPosition

List of usage examples for android.widget AdapterView getItemAtPosition

Introduction

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

Prototype

public Object getItemAtPosition(int position) 

Source Link

Document

Gets the data associated with the specified position in the list.

Usage

From source file:com.abroad.ruianju.im.ui.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    ListView mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
    }//from w ww. j  a  v  a 2s  .  co m
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = DemoHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}

From source file:com.avcall.app.ui.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    ListView mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
    }//from w  ww.  j  a va 2  s . c o  m
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = AvcallHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}

From source file:com.lykj.weixun.ui.chat.ui.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    ListView mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
    }/* w  w  w. j  a v  a 2 s  .  co m*/
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = DemoHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}

From source file:com.zhou.superwechat.ui.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    ListView mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
    }//from  w  ww .  j a v a2 s .  c  o  m
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = SuperWeChatHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}

From source file:cn.wyl.superwechat.ui.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    ListView mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
    }/*  w  w  w . j a va2  s .  c o m*/
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = SuperWeChatHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}

From source file:com.example.tony.popularmovie.MainActivityFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mMoviePosterAdapter = new MoviePosterAdapter(getActivity(), null, 0);

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    GridView gridview = (GridView) rootView.findViewById(R.id.gridview);
    gridview.setAdapter(mMoviePosterAdapter);

    gridview.setOnItemClickListener(new OnItemClickListener() {
        @Override/* www .java2  s.co m*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = (Cursor) parent.getItemAtPosition(position);
            String movieId = null;
            if (cursor.moveToPosition(position)) {
                movieId = cursor.getString(cursor.getColumnIndex(MovieContract.PopularEntry.COLUMN_MOVIE_ID));
            }

            ((Callback) getActivity()).onItemSelected(movieId);
        }
    });

    return rootView;
}

From source file:com.hzx.luoyechat.activity.RobotsActivity.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    inflateContentView(R.layout.fragment_robots, R.string.robot_chat, true);

    inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override//  w  ww  .j a  v a2 s .com
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}

From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java

public filter_dialog(Context cx, List<NameValuePair> data) {
    super(cx);//from w  w w.  ja  va 2 s  .c  o  m
    this.cx = cx;
    this.webData = data;
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    vocl = new View.OnClickListener() {
        public void onClick(View v) {
            onCheckboxClick(v);
        }
    };

    maxLines = new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView tv, int action, KeyEvent key) {
            boolean handled = false;
            if (action == EditorInfo.IME_ACTION_DONE) {
                setMaxLines(tv.getText().toString());
                tv.setText(getNamedData("iPage"));
                InputMethodManager imm = (InputMethodManager) tv.getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(tv.getWindowToken(), 0);
                handled = true;
            }
            return handled;
        }
    };
    rateListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            rateSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };
    licenseListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            licenseSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };
    placementListener = new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            placementSelected((String) parent.getItemAtPosition(pos));
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    };

}

From source file:br.unisinos.evertonlucas.passshelter.app.UsersNewGroupActivity.java

private void initializeAutoCompleteTextView() {
    tv = (DelayAutoCompleteTextView) findViewById(R.id.txt_search_user_new_group);
    tv.setThreshold(4);//from   www .  j  a va2  s  . co m
    tv.setAdapter(new UsersAutoCompleteAdapter(this));
    tv.setLoadingIndicator((ProgressBar) findViewById(R.id.pb_loading_indicator));
    tv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ParseUser user = (ParseUser) parent.getItemAtPosition(position);
            tv.setText("");
            insertUserIntoList(user);
        }
    });
}

From source file:cn.moon.superwechat.ui.RobotsActivity.java

@Override
@TargetApi(14)//from  w w w.  j  a v a 2  s  .c o  m
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    setContentView(R.layout.em_fragment_robots);
    inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    ListView mListView = (ListView) findViewById(R.id.list);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    if (android.os.Build.VERSION.SDK_INT >= 14) {
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light, android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
    }
    progressBar = findViewById(R.id.progress_bar);
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh() {
            getRobotNamesFromServer();
        }
    });
    Map<String, RobotUser> robotMap = SuperWeChatHelper.getInstance().getRobotList();
    if (robotMap != null) {
        robotList.addAll(robotMap.values());
    } else {
        progressBar.setVisibility(View.VISIBLE);
        getRobotNamesFromServer();
    }
    adapter = new RobotAdapter(this, 1, robotList);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new OnItemClickListener() {

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

            RobotUser user = (RobotUser) parent.getItemAtPosition(position);
            Intent intent = new Intent();
            intent.setClass(RobotsActivity.this, ChatActivity.class);
            intent.putExtra("userId", user.getUsername());
            startActivity(intent);
        }
    });
    mListView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (getWindow()
                    .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getCurrentFocus() != null)
                    inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);
            }
            return false;
        }
    });
}