Java Code Examples for android.widget.AdapterView.OnItemClickListener

The following examples show how to use android.widget.AdapterView.OnItemClickListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: socialauth-android   Source File: AlbumActivity.java    License: MIT License 6 votes vote down vote up
public void getData(final List<Album> albumList) {
	final GridView view = new GridView(this);
	getGridProperties(view);

	view.setAdapter(new AlbumsAdapter(AlbumActivity.this, 0, albumList));

	String[] urls = new String[albumList.size()];
	for (int i = 0; i < albumList.size(); i++) {
		urls[i] = albumList.get(i).getCoverPhoto();
	}

	view.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
			showPhoto(view, albumList, position);
			photoListFlag = true;
		}
	});
	dataSectionView.addView(view);
}
 
Example 2
Source Project: BonetCalendarView   Source File: ListBtYearViewProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View getView() {
	mListView = (ListView) LayoutInflater.from(getCalendar().getContext()).inflate(R.layout.month_list_view, null);
	mListView.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3) {
			if(! (getCalendar() ==null))
				getCalendar().notifyMonthChanged(new BtMonth(getYear(),position));
		}
	
	});

	mAdapter = new MonthListAdapter(getCalendar(),getYear());
	
	mListView.setAdapter(mAdapter);
	
	return mListView;
}
 
Example 3
Source Project: FlyWoo   Source File: AppVu.java    License: Apache License 2.0 6 votes vote down vote up
public void setOnItemClickListener() {
    gridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            AppItemVu vu = (AppItemVu) view.getTag();
            boolean isChecked = vu.toggleChecked();
            if(isChecked){
                //添加一个文件
                sendFileListener.addSendFile(list.get(position));
            }else{
                //移除一个文件
                sendFileListener.removeSendFile(list.get(position));
            }
            adapter.notifyDataSetChanged();
        }
    });
}
 
Example 4
Source Project: base-imageloader   Source File: ListImageDirPopupWindow.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initEvents()
{
	mListDir.setOnItemClickListener(new OnItemClickListener()
	{
		@Override
		public void onItemClick(AdapterView<?> parent, View view,
				int position, long id)
		{

			if (mImageDirSelected != null)
			{
				mImageDirSelected.selected(mDatas.get(position));
			}
		}
	});
}
 
Example 5
Source Project: biermacht   Source File: AlertBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public <T> AlertDialog.Builder searchableListAlert(final TextView text, final TextView title, final ArrayAdapter<T> adapter,
                                                   final ArrayList<T> list, final OnItemClickListener listener, TextWatcher textWatcher) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_searchable_list, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final ListView listView = (ListView) alertView.findViewById(R.id.list);
  listView.setOnItemClickListener(listener);
  listView.setAdapter(adapter);

  // Search text watcher.
  editText.addTextChangedListener(textWatcher);
  textWatcher.onTextChanged("", 0, 0, 0);

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setNegativeButton(R.string.cancel, null);
}
 
Example 6
Source Project: UltimateAndroid   Source File: FoldingActivitys.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.folding_drawer_activity);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, testValues);
    listView = (ListView) findViewById(R.id.foldingDrawerListView1);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                long arg3) {
            Intent intent = new Intent();
            intent.setClassName(FoldingActivitys.this, "com.marshalchen.common.demoofui.foldingDrawer." + testValues[arg2]
                    + "Activity");

            startActivity(intent);

        }
    });

}
 
Example 7
Source Project: Mizuu   Source File: UnidentifiedMovies.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	mList = (ListView) findViewById(R.id.listView1);
	mList.setChoiceMode(ListView.CHOICE_MODE_NONE);
	mList.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
			Intent intent = new Intent(UnidentifiedMovies.this, IdentifyMovie.class);
			intent.putExtra("fileName", mFilepaths.get(arg2).getFullFilepath());
			startActivityForResult(intent, 0);
		}
	});

	loadData();

	LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(LocalBroadcastUtils.UPDATE_MOVIE_LIBRARY));
}
 
Example 8
Source Project: sctalk   Source File: YayaEmoGridView.java    License: Apache License 2.0 6 votes vote down vote up
private GridView getViewPagerItem(final int index) {
    GridView gridView = new GridView(_context);
    gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    gridView.setNumColumns(4);
    gridView.setVerticalScrollBarEnabled(false);
    gridView.setHorizontalScrollBarEnabled(false);
    gridView.setPadding(8, 8, 8, 0);
    gridView.setVerticalSpacing(20);
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

    gridView.setAdapter(new YayaEmoGridViewAdapter(_context,
            getGridViewData(index)));
    gridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            int start = index * SysConstant.yayaPageSize;
            onEmoGridViewItemClick.onItemClick(position + start, index);
        }
    });
    return gridView;
}
 
Example 9
Source Project: talk-android   Source File: RecipientEditTextView.java    License: MIT License 6 votes vote down vote up
private void showAddress(final DrawableRecipientChip currentChip, final ListPopupWindow popup,
                         int width) {
    if (!mAttachedToWindow) {
        return;
    }
    int line = getLayout().getLineForOffset(getChipStart(currentChip));
    int bottom = calculateOffsetFromBottom(line);
    // Align the alternates popup with the left side of the View,
    // regardless of the position of the chip tapped.
    popup.setWidth(width);
    popup.setAnchorView(this);
    popup.setVerticalOffset(bottom);
    popup.setAdapter(createSingleAddressAdapter(currentChip));
    popup.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            unselectChip(currentChip);
            popup.dismiss();
        }
    });
    popup.show();
    ListView listView = popup.getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setItemChecked(0, true);
}
 
Example 10
public void showPicker() {
    cleanupPending(); // remove any currently pending device
    hidePicker();

    pickerDialog = picker.getPickerDialog(activity.getString(selectDeviceResId), new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int pos,
                long id) {
            ConnectableDevice device = (ConnectableDevice) adapter.getItemAtPosition(pos);

            selectDevice(device);
        }
    });

    pickerDialog.show();
}
 
Example 11
Source Project: coursera-android   Source File: ListViewActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Create a new Adapter containing a list of colors
	// Set the adapter on this ListActivity's built-in ListView
	setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
			getResources().getStringArray(R.array.colors)));

	ListView lv = getListView();

	// Enable filtering when the user types in the virtual keyboard
	lv.setTextFilterEnabled(true);

	// Set an setOnItemClickListener on the ListView
	lv.setOnItemClickListener(new OnItemClickListener() {
		public void onItemClick(AdapterView<?> parent, View view,
				int position, long id) {

			// Display a Toast message indicting the selected item
			Toast.makeText(getApplicationContext(),
					((TextView) view).getText(), Toast.LENGTH_SHORT).show();
		}
	});
}
 
Example 12
Source Project: KJFrameForAndroid   Source File: EmojiPageFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    sGrid = new GridView(getActivity());
    sGrid.setNumColumns(KJEmojiConfig.COLUMNS);
    adapter = new EmojiGridAdapter(getActivity(), datas);
    sGrid.setAdapter(adapter);
    sGrid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            EditText editText = (EditText) getActivity().findViewById(
                    R.id.emoji_titile_input);
            if (position + 1 != datas.size()) {
                InputHelper.input(editText, (Emojicon) parent.getAdapter()
                        .getItem(position));
            } else {
                InputHelper.backspace(editText);
            }
        }
    });
    sGrid.setSelector(new ColorDrawable(Color.TRANSPARENT));
    return sGrid;
}
 
Example 13
/**
 * Callback to listener when date is valid (not disable, not outside of
 * min/max date)
 * 
 * @return
 */
private OnItemClickListener getDateItemClickListener() {
	dateItemClickListener = new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> parent, View view,
				int position, long id) {

			DateTime dateTime = dateInMonthsList.get(position);

			if (caldroidListener != null) {
				if ((minDateTime != null && dateTime.lt(minDateTime))
						|| (maxDateTime != null && dateTime.gt(maxDateTime))
						|| (disableDates != null && disableDates
								.indexOf(dateTime) != -1)) {
					return;
				}

				Date date = CalendarHelper.convertDateTimeToDate(dateTime);
				caldroidListener.onSelectDate(date, view);
			}
		}
	};

	return dateItemClickListener;
}
 
Example 14
Source Project: Moring-Alarm   Source File: BirdGridFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	if (mPos == -1 && savedInstanceState != null)
		mPos = savedInstanceState.getInt("mPos");
	TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
	mImgRes = imgs.getResourceId(mPos, -1);
	
	GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null);
	gv.setBackgroundResource(android.R.color.black);
	gv.setAdapter(new GridAdapter());
	gv.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			if (getActivity() == null)
				return;
			ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity();
			activity.onBirdPressed(mPos);
		}			
	});
	return gv;
}
 
Example 15
Source Project: Moring-Alarm   Source File: BirdGridFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	if (mPos == -1 && savedInstanceState != null)
		mPos = savedInstanceState.getInt("mPos");
	TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
	mImgRes = imgs.getResourceId(mPos, -1);
	
	GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null);
	gv.setBackgroundResource(android.R.color.black);
	gv.setAdapter(new GridAdapter());
	gv.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			if (getActivity() == null)
				return;
			ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity();
			activity.onBirdPressed(mPos);
		}			
	});
	return gv;
}
 
Example 16
Source Project: TraceByAmap   Source File: CloudDetailActivity.java    License: MIT License 5 votes vote down vote up
private void setGridView() {
	int size = mImageitem.size();
	int length = 60;
	DisplayMetrics dm = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(dm);
	float density = dm.density;
	int gridviewWidth = (int) (size * (length + 4) * density);
	int itemWidth = (int) (length * density);

	LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
			gridviewWidth, LinearLayout.LayoutParams.MATCH_PARENT);
	mgridView.setLayoutParams(params); // 设置GirdView布局参数,横向布局的关键
	mgridView.setColumnWidth(itemWidth); // 设置列表项宽
	mgridView.setHorizontalSpacing(5); // 设置列表项水平间距
	mgridView.setStretchMode(GridView.NO_STRETCH);
	mgridView.setNumColumns(size); // 设置列数量=列表集合数

	GridViewAdapter adapter = new GridViewAdapter(getApplicationContext());
	mgridView.setAdapter(adapter);
	mgridView.setOnItemClickListener(new OnItemClickListener() {

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

}
 
Example 17
@Override
protected View onCreateDialogView() {
	fileExplorer = new FileExplorerAdapter();
	
	LinearLayout layout = new LinearLayout(getContext());
	layout.setOrientation(LinearLayout.VERTICAL);
	
	pathTextView = new TextView(getContext());
	pathTextView.setText(fileExplorer.getCurrentPath());
	
	listView = new ListView(getContext());
	listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
	listView.setAdapter(fileExplorer);
	listView.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			if(fileExplorer.changeDir(position)) {
				listView.setItemChecked(listView.getCheckedItemPosition(), false);
				pathTextView.setText(fileExplorer.getCurrentPath());
			}
		}
	});
	
	layout.addView(pathTextView);
	layout.addView(listView);
	return layout;
}
 
Example 18
Source Project: CSipSimple   Source File: IcsSpinner.java    License: GNU General Public License v3.0 5 votes vote down vote up
public DropdownPopup(Context context, AttributeSet attrs, int defStyleRes) {
    super(context, attrs, 0, defStyleRes);

    setAnchorView(IcsSpinner.this);
    setModal(true);
    setPromptPosition(POSITION_PROMPT_ABOVE);
    setOnItemClickListener(new OnItemClickListener() {
        @SuppressWarnings("rawtypes")
        public void onItemClick(AdapterView parent, View v, int position, long id) {
            IcsSpinner.this.setSelection(position);
            dismiss();
        }
    });
}
 
Example 19
Source Project: BotLibre   Source File: ListCategoriesView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list_view);
	
	
	
	Bundle bundle = getIntent().getExtras();
   	setType(bundle.getString("type"));
   	
   	
   	
	llview = (ListView) findViewById(R.id.theListView);
	txt = (TextView) findViewById(R.id.theTitle);
	
	
	txt.setText("Select Categories");
	llview.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
			//Getting Info from the main class of the categories.EX name, icon, ...etc
			ContentConfig categories = (ContentConfig) (llview.getItemAtPosition(arg2));
			//using categories to pass the data for all
			Toast.makeText(ListCategoriesView.this, categories.name  + " Selected", Toast.LENGTH_SHORT).show();
			data.putExtra("cat", categories.name);
			setResult(RESULT_OK,data);
			finish();
		}
	});
	HttpAction action = new HttpGetCategoriesAction(this, getType());
   	action.execute();
	
}
 
Example 20
Source Project: UltimateAndroid   Source File: TeamDetails.java    License: Apache License 2.0 5 votes vote down vote up
private OnItemClickListener createMeetingListClickListener() {
    return new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String meetingTime = meetingListAdapter.getItem(position);

            Intent intent = new Intent(TeamDetails.this, MeetingDetails.class);
            intent.putExtra("teamName", team.getName());
            intent.putExtra("meetingTime", meetingTime);
            startActivity(intent);
        }
    };
}
 
Example 21
Source Project: ui   Source File: Phone_frag.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View myView = inflater.inflate(R.layout.phone_frag, container, false);

       ListView list = (ListView) myView.findViewById(R.id.ListView01);
       list.setClickable(true);

       final List<Phonebook> listOfPhonebook = new ArrayList<Phonebook>();
       listOfPhonebook.add(new Phonebook("Test", "9981728", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test1", "1234455", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test2", "00000", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test3", "00000", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test4", "00000", "test4test.com"));
       listOfPhonebook.add(new Phonebook("Test5", "00000", "[email protected]"));
       listOfPhonebook.add(new Phonebook("Test6", "00000", "[email protected]"));

       PhonebookAdapter adapter = new PhonebookAdapter(myContext, listOfPhonebook);

       list.setOnItemClickListener(new OnItemClickListener() {

           @Override
           public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
               showToast(listOfPhonebook.get(position).getName());
           }
       });

       list.setAdapter(adapter);
       
       return myView;
   }
 
Example 22
Source Project: BotLibre   Source File: ListTemplateView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list_view);
	

	llview = (ListView) findViewById(R.id.theListView);
	txt=(TextView) findViewById(R.id.theTitle);
	txt.setText("Select Template");

	adapter = new ImageListAdapter(this,
               R.layout.image_list, (List) MainActivity.getAllTemplates(this));
	llview.setAdapter(adapter);
	
	llview.setOnItemClickListener(new OnItemClickListener() {
		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
			
			InstanceConfig templates = (InstanceConfig) (llview.getItemAtPosition(arg2));
			Toast.makeText(ListTemplateView.this, templates.name + " Selected", Toast.LENGTH_SHORT).show();
			data.putExtra("template", templates.name);
			setResult(RESULT_OK,data);
			finish();
		}
	});
	
	HttpAction action = new HttpGetTemplatesAction(this);
   	action.execute();
	
}
 
Example 23
Source Project: AndroidLinkup   Source File: Rank.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置关卡选择的监听器
 * 
 * @param levelListener
 *            选择关卡操作接口
 */
public void setLevelLister(final ISelectedLevel levelListener) {
    holder.rankGrid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (levelListener != null) {
                levelListener.onSelectedLevel(rankCfg.getLevelInfos().get(arg2));
            }
        }
    });
}
 
Example 24
Source Project: CountryCodePicker   Source File: CountryCodeDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void setupListView(ListView listView) {
  mArrayAdapter = new CountryCodeArrayAdapter(getContext(), mFilteredCountries, mCountryCodePicker);

  if (!mCountryCodePicker.isSelectionDialogShowSearch()) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) listView.getLayoutParams();
    params.height = ListView.LayoutParams.WRAP_CONTENT;
    listView.setLayoutParams(params);
  }

  OnItemClickListener listener = new OnItemClickListener() {
    @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      if (mFilteredCountries == null) {
        Log.e(TAG, "no filtered countries found! This should not be happened, Please report!");
        return;
      }

      if (mFilteredCountries.size() < position || position < 0) {
        Log.e(TAG, "Something wrong with the ListView. Please report this!");
        return;
      }

      Country country = mFilteredCountries.get(position);
      /* view is only a separator, so the country is null and we ignore it.
       see {@link #getFilteredCountries(String)} */
      if (country == null) return;

      mCountryCodePicker.setSelectedCountry(country);
      mInputMethodManager.hideSoftInputFromWindow(mEdtSearch.getWindowToken(), 0);
      dismiss();
    }
  };
  listView.setOnItemClickListener(listener);
  listView.setAdapter(mArrayAdapter);
}
 
Example 25
Source Project: letv   Source File: PointsActivtiy.java    License: Apache License 2.0 5 votes vote down vote up
public void initListText(final PointBeanList bean) {
    this.list.setAdapter(new PointItemAdapter(this, bean));
    this.list.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            Intent intent = new Intent();
            intent.putExtra("my_points", Integer.parseInt(((PointBean) bean.get(position)).credit) * ((PointBean) bean.get(position)).state);
            intent.putExtra("flag", position);
            intent.setClass(PointsActivtiy.this, TaskDetailActivity.class);
            PointsActivtiy.this.startActivity(intent);
        }
    });
}
 
Example 26
Source Project: Conquer   Source File: ChatActivity.java    License: Apache License 2.0 5 votes vote down vote up
private View getGridView(final int i) {
	View view = View.inflate(this, R.layout.include_emo_gridview, null);
	GridView gridview = (GridView) view.findViewById(R.id.gridview);
	List<FaceText> list = new ArrayList<FaceText>();
	if (i == 0) {
		list.addAll(emos.subList(0, 21));
	} else if (i == 1) {
		list.addAll(emos.subList(21, emos.size()));
	}
	final EmoteAdapter gridAdapter = new EmoteAdapter(ChatActivity.this, list);
	gridview.setAdapter(gridAdapter);
	gridview.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
			FaceText name = (FaceText) gridAdapter.getItem(position);
			String key = name.text.toString();
			try {
				if (edit_user_comment != null && !TextUtils.isEmpty(key)) {
					int start = edit_user_comment.getSelectionStart();
					CharSequence content = edit_user_comment.getText().insert(start, key);
					edit_user_comment.setText(content);
					// 定位光标位置
					CharSequence info = edit_user_comment.getText();
					if (info instanceof Spannable) {
						Spannable spanText = (Spannable) info;
						Selection.setSelection(spanText, start + key.length());
					}
				}
			} catch (Exception e) {

			}

		}
	});
	return view;
}
 
Example 27
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(App.theme.theme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_app_list);
    Utils.checkBackups(getApplicationContext());
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setTitle(Ui.applyCustomTypeFace(getString(R.string.app_name), this));
    }

    loadingView = findViewById(R.id.loadingView);
    emptyView = findViewById(R.id.emptyView);
    listView = (StickyListHeadersListView) findViewById(R.id.listView);
    listView.setDrawingListUnderStickyHeader(false);
    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (isRootAccessGiven) {
                startPreferencesActivity((AppEntry) mAdapter.getItem(arg2));
            } else {
                checkRoot();
            }
        }
    });

    if (savedInstanceState == null) {
        checkRoot();
    }

    if (savedInstanceState == null || Utils.getPreviousApps() == null) {
        startTask();
    } else {
        updateListView(Utils.getPreviousApps());
    }
}
 
Example 28
@Override
public void onClick(final View v) {
    for (ViewParent p = v.getParent(); p != null; p = p.getParent()) {
        if (p instanceof ListView) {
            final ListView list = (ListView) p;
            final OnItemClickListener l = list.getOnItemClickListener();
            if (l != null) {
                l.onItemClick(list, v, ((Integer) v.getTag()).intValue(), 0);
            }
            return;
        }
    }

}
 
Example 29
Source Project: coursera-android   Source File: GridFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);
	
	mGridview.setAdapter(new ImageAdapter(getActivity(), mThumbNailIDs));
	mGridview.setOnItemClickListener(new OnItemClickListener() {
		public void onItemClick(AdapterView<?> parent, View v,
				int position, long id) {
			Intent intent = new Intent(getActivity(),
					ImageViewActivity.class);
			intent.putExtra(EXTRA_RES_ID, (int) id);
			startActivity(intent);
		}
	});
}
 
Example 30
Source Project: BonetCalendarView   Source File: GridBtMonthViewProvider.java    License: Apache License 2.0 5 votes vote down vote up
public GridBtMonthViewProvider(Context context, BtMonth month) {
	super(month);
	
	mContext = context;
	
	Log.d("", "Criando DayGridAdapter");
	mAdapter = new DayGridAdapter(context,month,getMinDate(),getMaxDate());

	mMonthDisplay = new MonthDisplayHelper(month.getYear(), month.getMonth());

	mGridItemClickedListener = new OnItemClickListener() {
		
		@Override
		public void onItemClick(AdapterView<?> adapter, View arg1, int position,
				long arg3) {
			
			int fp = mMonthDisplay.getRowOf(1)*7+mMonthDisplay.getColumnOf(1);
			int lp = fp+ mMonthDisplay.getNumberOfDaysInMonth();
			
			// Checks to see if the position selected represents a date within the month
			if(position >= fp && position <lp) {
			
				BtDate day;
				// Checks to see if the selected date is within the defined bounds
				if( (day = getMonth().getDate(position+1-fp)).isWithinBounds(getMinDate(),getMaxDate()))
					selectDay(day);
				
			}
		}
	};
	
}