use of android.view.View.OnClickListener in project UltimateAndroid by cymcsg.
the class ImageGridAdapter method getView.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final Holder holder;
if (convertView == null) {
holder = new Holder();
convertView = View.inflate(act, R.layout.group_item_image_grid, null);
holder.iv = (ImageView) convertView.findViewById(R.id.image);
holder.selected = (ImageView) convertView.findViewById(R.id.isselected);
holder.text = (TextView) convertView.findViewById(R.id.item_image_grid_text);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
final ImageItem item = dataList.get(position);
holder.iv.setTag(item.imagePath);
cache.displayBmp(holder.iv, item.thumbnailPath, item.imagePath, callback);
if (item.isSelected) {
holder.selected.setImageResource(R.drawable.icon_data_select);
holder.text.setBackgroundResource(R.drawable.icon_bgd_relatly_line);
} else {
holder.selected.setImageBitmap(null);
holder.text.setBackgroundColor(0x00000000);
}
holder.iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String path = dataList.get(position).imagePath;
if ((Bimp.drr.size() + selectTotal) < 9) {
item.isSelected = !item.isSelected;
if (item.isSelected) {
holder.selected.setImageResource(R.drawable.icon_data_select);
holder.text.setBackgroundResource(R.drawable.icon_bgd_relatly_line);
selectTotal++;
if (textcallback != null)
textcallback.onListen(selectTotal);
map.put(path, path);
} else if (!item.isSelected) {
holder.selected.setImageResource(-1);
holder.text.setBackgroundColor(0x00000000);
selectTotal--;
if (textcallback != null)
textcallback.onListen(selectTotal);
map.remove(path);
}
} else if ((Bimp.drr.size() + selectTotal) >= 9) {
if (item.isSelected == true) {
item.isSelected = !item.isSelected;
holder.selected.setImageResource(-1);
selectTotal--;
map.remove(path);
} else {
Message message = Message.obtain(mHandler, 0);
message.sendToTarget();
}
}
}
});
return convertView;
}
use of android.view.View.OnClickListener in project Libraries-for-Android-Developers by eoecn.
the class RequestActivity method onCreate.
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.request_activity);
btn01 = (Button) findViewById(R.id.btn01);
et01 = (EditText) findViewById(R.id.et01);
et02 = (EditText) findViewById(R.id.et02);
btn01.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.putExtra(KEY_USER_ID, et01.getText().toString());
intent.putExtra(KEY_USER_PASSWORD, et02.getText().toString());
setResult(RESULT_OK, intent);
finish();
}
});
}
use of android.view.View.OnClickListener in project android-app by eoecn.
the class CaptureActivity method initControl.
private void initControl() {
viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
mTitle = (TextView) findViewById(R.id.details_textview_title);
mTitle.setText(R.string.scan_title);
mGoHome = (ImageView) findViewById(R.id.details_imageview_gohome);
mGoHome.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
use of android.view.View.OnClickListener in project StickyListHeaders by emilsjolander.
the class AdapterWrapper method configureHeader.
/**
* Get a header view. This optionally pulls a header from the supplied
* {@link WrapperView} and will also recycle the divider if it exists.
*/
private View configureHeader(WrapperView wv, final int position) {
View header = wv.mHeader == null ? popHeader() : wv.mHeader;
header = mDelegate.getHeaderView(position, header, wv);
if (header == null) {
throw new NullPointerException("Header view must not be null.");
}
//if the header isn't clickable, the listselector will be drawn on top of the header
header.setClickable(true);
header.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mOnHeaderClickListener != null) {
long headerId = mDelegate.getHeaderId(position);
mOnHeaderClickListener.onHeaderClick(v, position, headerId);
}
}
});
return header;
}
use of android.view.View.OnClickListener in project android_frameworks_base by ParanoidAndroid.
the class PreferenceActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.android.internal.R.layout.preference_list_content);
mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
boolean hidingHeaders = onIsHidingHeaders();
mSinglePane = hidingHeaders || !onIsMultiPane();
String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
int initialTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE, 0);
int initialShortTitle = getIntent().getIntExtra(EXTRA_SHOW_FRAGMENT_SHORT_TITLE, 0);
if (savedInstanceState != null) {
// We are restarting from a previous saved state; used that to
// initialize, instead of starting fresh.
ArrayList<Header> headers = savedInstanceState.getParcelableArrayList(HEADERS_TAG);
if (headers != null) {
mHeaders.addAll(headers);
int curHeader = savedInstanceState.getInt(CUR_HEADER_TAG, (int) HEADER_ID_UNDEFINED);
if (curHeader >= 0 && curHeader < mHeaders.size()) {
setSelectedHeader(mHeaders.get(curHeader));
}
}
} else {
if (initialFragment != null && mSinglePane) {
// If we are just showing a fragment, we want to run in
// new fragment mode, but don't need to compute and show
// the headers.
switchToHeader(initialFragment, initialArguments);
if (initialTitle != 0) {
CharSequence initialTitleStr = getText(initialTitle);
CharSequence initialShortTitleStr = initialShortTitle != 0 ? getText(initialShortTitle) : null;
showBreadCrumbs(initialTitleStr, initialShortTitleStr);
}
} else {
// We need to try to build the headers.
onBuildHeaders(mHeaders);
// the currently selected preference fragment.
if (mHeaders.size() > 0) {
if (!mSinglePane) {
if (initialFragment == null) {
Header h = onGetInitialHeader();
switchToHeader(h);
} else {
switchToHeader(initialFragment, initialArguments);
}
}
}
}
}
// visibility for other configurations.
if (initialFragment != null && mSinglePane) {
// Single pane, showing just a prefs fragment.
findViewById(com.android.internal.R.id.headers).setVisibility(View.GONE);
mPrefsContainer.setVisibility(View.VISIBLE);
if (initialTitle != 0) {
CharSequence initialTitleStr = getText(initialTitle);
CharSequence initialShortTitleStr = initialShortTitle != 0 ? getText(initialShortTitle) : null;
showBreadCrumbs(initialTitleStr, initialShortTitleStr);
}
} else if (mHeaders.size() > 0) {
setListAdapter(new HeaderAdapter(this, mHeaders));
if (!mSinglePane) {
// Multi-pane.
getListView().setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
if (mCurHeader != null) {
setSelectedHeader(mCurHeader);
}
mPrefsContainer.setVisibility(View.VISIBLE);
}
} else {
// If there are no headers, we are in the old "just show a screen
// of preferences" mode.
setContentView(com.android.internal.R.layout.preference_list_content_single);
mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs);
mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE);
mPreferenceManager.setOnPreferenceTreeClickListener(this);
}
// see if we should show Back/Next buttons
Intent intent = getIntent();
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
findViewById(com.android.internal.R.id.button_bar).setVisibility(View.VISIBLE);
Button backButton = (Button) findViewById(com.android.internal.R.id.back_button);
backButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_CANCELED);
finish();
}
});
Button skipButton = (Button) findViewById(com.android.internal.R.id.skip_button);
skipButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_OK);
finish();
}
});
mNextButton = (Button) findViewById(com.android.internal.R.id.next_button);
mNextButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
setResult(RESULT_OK);
finish();
}
});
// set our various button parameters
if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
if (TextUtils.isEmpty(buttonText)) {
mNextButton.setVisibility(View.GONE);
} else {
mNextButton.setText(buttonText);
}
}
if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
if (TextUtils.isEmpty(buttonText)) {
backButton.setVisibility(View.GONE);
} else {
backButton.setText(buttonText);
}
}
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
skipButton.setVisibility(View.VISIBLE);
}
}
}
Aggregations