Example usage for android.view View.OnClickListener View.OnClickListener

List of usage examples for android.view View.OnClickListener View.OnClickListener

Introduction

In this page you can find the example usage for android.view View.OnClickListener View.OnClickListener.

Prototype

View.OnClickListener

Source Link

Usage

From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    mTickersContainer = (FixedGridView) getView().findViewById(R.id.tickersContainer);
    mTickersContainer.setExpanded(true);
    final int dashboardSpacing = getResources().getDimensionPixelSize(R.dimen.dashboard_spacing);
    final int dashboardItemSize = getResources().getDimensionPixelSize(R.dimen.dashboard_item_size);
    mTickersContainer.getViewTreeObserver()
            .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override/*from   www . ja v a 2  s  .  com*/
                public void onGlobalLayout() {
                    if (mTickersDashboardAdapter.getNumColumns() == 0) {
                        final int numColumns = (int) Math
                                .floor(mTickersContainer.getWidth() / (dashboardSpacing + dashboardItemSize));
                        if (numColumns > 0) {
                            mTickersDashboardAdapter.setNumColumns(numColumns);
                            mTickersContainer.setNumColumns(numColumns);
                        }
                    }
                }
            });
    mTickersDashboardAdapter = new TickersDashboardAdapter(getActivity(), this);
    updateStorageWithTickers();
    mTickersDashboardAdapter.update();
    mTickersContainer.setAdapter(mTickersDashboardAdapter);
    TextView emptyView = (TextView) getView().findViewById(R.id.emptyView);
    mTickersContainer.setEmptyView(emptyView);
    mTickersContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return event.getAction() == MotionEvent.ACTION_MOVE;
        }
    });

    //Broadcast receiver initialization
    mGetStatsReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (isVisible()) {
                if (mRefreshItem != null) {
                    mRefreshItem.collapseActionView();
                    mRefreshItem.setActionView(null);
                }
                mTickersDashboardAdapter.update();
            }
        }
    };

    LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(mGetStatsReceiver,
            new IntentFilter("UpdateTickers"));

    //Trade listener, once "Buy" or "Sell" clicked, send the order to server
    View.OnClickListener tradeListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new RegisterTradeRequestTask().execute((v.getId() == R.id.BuyButton) ? "buy" : "sell");
        }
    };

    Button SellButton = (Button) getView().findViewById(R.id.SellButton);
    Button BuyButton = (Button) getView().findViewById(R.id.BuyButton);
    SellButton.setOnClickListener(tradeListener);
    BuyButton.setOnClickListener(tradeListener);

    Button UpdateAccountInfoButton = (Button) getView().findViewById(R.id.UpdateAccountInfoButton);

    UpdateAccountInfoButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new UpdateFundsTask().execute();
        }
    });

    //start service to get new data once Dashboard is opened
    getActivity().sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class));
}

From source file:com.daniel.view.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view/*  www  .j ava  2s .c  om*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition);
        }
    });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                closeOpenedItems();
                openAnimate(downPosition);
                return false;
            }
        });
    }
}

From source file:cm.aptoide.ptdev.ScheduledDownloadsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Aptoide.getThemePicker().setAptoideTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.page_sch_downloads);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setTitle(getString(R.string.setting_schdwntitle));

    lv = (ListView) findViewById(android.R.id.list);
    lv.setDivider(null);/*w w w  .  ja v a  2  s  .  co m*/
    db = new Database(Aptoide.getDb());
    bindService(new Intent(this, DownloadService.class), conn, Context.BIND_AUTO_CREATE);

    adapter = new CursorAdapter(this, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) {

        @Override
        public View newView(Context context, Cursor arg1, ViewGroup arg2) {
            return LayoutInflater.from(context).inflate(R.layout.row_sch_download, null);
        }

        @Override
        public void bindView(View convertView, Context arg1, Cursor c) {
            // Planet to display
            ScheduledDownload scheduledDownload = scheduledDownloadsHashMap
                    .get(c.getLong(c.getColumnIndex("_id")));

            // The child views in each row.
            CheckBox checkBoxScheduled;
            TextView textViewName;
            TextView textViewVersion;
            ImageView imageViewIcon;

            // Create a new row view
            if (convertView.getTag() == null) {

                // Find the child views.
                textViewName = (TextView) convertView.findViewById(R.id.name);
                textViewVersion = (TextView) convertView.findViewById(R.id.appversion);
                checkBoxScheduled = (CheckBox) convertView.findViewById(R.id.schDwnChkBox);
                imageViewIcon = (ImageView) convertView.findViewById(R.id.appicon);
                // Optimization: Tag the row with it's child views, so we don't have to
                // call findViewById() later when we reuse the row.
                convertView.setTag(new Holder(textViewName, textViewVersion, checkBoxScheduled, imageViewIcon));

                // If CheckBox is toggled, update the planet it is tagged with.
                checkBoxScheduled.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        CheckBox cb = (CheckBox) v;
                        ScheduledDownload schDownload = (ScheduledDownload) cb.getTag();
                        schDownload.setChecked(cb.isChecked());
                    }
                });
            }
            // Reuse existing row view
            else {
                // Because we use a ViewHolder, we avoid having to call findViewById().
                Holder viewHolder = (Holder) convertView.getTag();
                checkBoxScheduled = viewHolder.checkBoxScheduled;
                textViewVersion = viewHolder.textViewVersion;
                textViewName = viewHolder.textViewName;
                imageViewIcon = viewHolder.imageViewIcon;
            }

            // Tag the CheckBox with the Planet it is displaying, so that we can
            // access the planet in onClick() when the CheckBox is toggled.
            checkBoxScheduled.setTag(scheduledDownload);

            // Display planet data
            checkBoxScheduled.setChecked(scheduledDownload.isChecked());
            textViewName.setText(scheduledDownload.getName());
            textViewVersion.setText(scheduledDownload.getVername());

            ImageLoader.getInstance().displayImage(scheduledDownload.getIconPath(), imageViewIcon);

        }
    };

    getSupportLoaderManager().initLoader(0, null, this);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View item, int arg2, long arg3) {
            ScheduledDownload scheduledDownload = (ScheduledDownload) ((Holder) item.getTag()).checkBoxScheduled
                    .getTag();
            scheduledDownload.toggleChecked();
            Holder viewHolder = (Holder) item.getTag();
            viewHolder.checkBoxScheduled.setChecked(scheduledDownload.isChecked());
        }

    });

    if (getIntent().hasExtra("downloadAll")) {
        ScheduledDownloadsDialog pd = new ScheduledDownloadsDialog();
        pd.show(getSupportFragmentManager(), "installAllScheduled");
    }

    lv.setAdapter(adapter);
}

From source file:app.screen.ServiceControlFragment.java

/** wire the buttons to start/stop the service */
private void _wireStartStopButtons() {
    myViews.btn_startservice.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            MyService.startServiceNow(getActivity());
        }/*from   w  w w  .j  a v a 2s . c  o m*/
    });

    myViews.btn_stopservice.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            LocalEventsManager.fireEvent(getActivity(), LocalEvents.ShutdownMyService, null, null);
        }
    });

    getAppData().observablePropertyManager.addPropertyChangeObserver(new ObservablePropertyListener() {
        public ObservableProperty getProperty() {
            return ObservableProperty.ServiceIsStarted;
        }

        public String getName() {
            return "MyActivity service start/stop buttons";
        }

        public void onChange(String propertyName, Object value) {
            if (value == Boolean.TRUE) {
                myViews.btn_startservice.setEnabled(false);
                myViews.btn_stopservice.setEnabled(true);
            } else {
                myViews.btn_startservice.setEnabled(true);
                myViews.btn_stopservice.setEnabled(false);
            }
        }
    }, true);

}

From source file:uk.ac.hutton.ics.buntata.activity.LogDetailsActivity.java

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

    ButterKnife.bind(this);

    Bundle args = getIntent().getExtras();

    if (args != null) {
        datasourceId = args.getInt(PARAM_DATASOURCE_ID, -1);
        nodeId = args.getInt(PARAM_NODE_ID, -1);
        logId = args.getInt(PARAM_LOG_ID, -1);
    }/* w w  w.  j  a  va 2  s .c  o m*/

    setSupportActionBar(toolbar);

    DatasourceManager datasourceManager = new DatasourceManager(this, datasourceId);
    NodeManager nodeManager = new NodeManager(this, datasourceId);
    imageManager = new LogEntryImageManager(this);

    logManager = new LogEntryManager(this);
    log = logManager.getById(logId);

    if (log == null) {
        BuntataNodeAdvanced node = nodeManager.getById(nodeId);
        log = new LogEntry();
        log.setDatasourceId(datasourceId);
        log.setNodeId(node.getId());
        log.setNodeName(node.getName());

        /* If this is a new entry, then definitely ask to save */
        unsavedChanges = true;
    }

    datasource.setText(datasourceManager.getById(log.getDatasourceId()).getName());
    nodeName.setText(nodeManager.getById(log.getNodeId()).getName());
    latitude.setFilters(new InputFilter[] { new InputFilterMinMax(-90, 90) });
    longitude.setFilters(new InputFilter[] { new InputFilterMinMax(-180, 180) });
    note.setText(log.getNote());
    if (log.getLatitute() != null)
        latitude.setText(DECIMAL_FORMAT.format(log.getLatitute()));
    if (log.getLongitude() != null)
        longitude.setText(DECIMAL_FORMAT.format(log.getLongitude()));

    datasource.setInputType(InputType.TYPE_NULL);
    nodeName.setInputType(InputType.TYPE_NULL);

    gpsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startLocationTracking();
        }
    });

    latitude.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b) {
                try {
                    double newValue = Double.parseDouble(latitude.getText().toString());

                    if (log.getLatitute() == null || log.getLatitute() != newValue) {
                        log.setLatitute(newValue);
                        unsavedChanges = true;
                    }
                } catch (Exception e) {
                }
            }
        }
    });
    longitude.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b) {
                try {
                    double newValue = Double.parseDouble(longitude.getText().toString());

                    if (log.getLongitude() == null || log.getLongitude() != newValue) {
                        log.setLongitude(newValue);
                        unsavedChanges = true;
                    }
                } catch (Exception e) {
                }
            }
        }
    });

    note.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (!b) {
                String newText = note.getText().toString();

                if (!StringUtils.areEqual(newText, log.getNote())) {
                    log.setNote(newText);
                    unsavedChanges = true;
                }
            }
        }
    });

    GoogleAnalyticsUtils.trackEvent(this, getTracker(TrackerName.APP_TRACKER),
            getString(R.string.ga_event_category_log), getString(R.string.ga_event_action_node_view),
            log.getNodeName());

    /* Set the toolbar as the action bar */
    if (getSupportActionBar() != null) {
        /* Set the title */
        getSupportActionBar().setTitle(log == null ? getString(R.string.log_add_title) : log.getNodeName());
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    updateImageSection();
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * Called when the activity is starting. Initializes the corresponding
 * call interface.//  ww w  .  j  a  v a  2 s . c o  m
 *
 * @param savedInstanceState If the activity is being re-initialized after
 * previously being shut down then this Bundle contains the data it most
 * recently supplied in onSaveInstanceState(Bundle).
 * Note: Otherwise it is null.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.video_call);

    this.callIdentifier = getIntent().getExtras().getString(CallManager.CALL_IDENTIFIER);

    call = CallManager.getActiveCall(callIdentifier);

    if (call == null) {
        logger.error("There's no call with id: " + callIdentifier);
        return;
    }

    callConference = call.getConference();

    initSpeakerphoneButton();
    initMicrophoneView();
    initHangupView();

    // Registers as the call state listener
    call.addCallChangeListener(this);

    View toastView = findViewById(R.id.clickable_toast);
    View.OnClickListener toastclickHandler = new View.OnClickListener() {
        public void onClick(View v) {
            showZrtpInfoDialog();
            sasToastController.hideToast(true);
        }
    };

    if (AndroidUtils.hasAPI(11)) {
        sasToastController = new ClickableToastController(toastView, toastclickHandler);
    } else {
        sasToastController = new LegacyClickableToastCtrl(toastView, toastclickHandler);
    }

    if (savedInstanceState == null) {
        VideoHandlerFragment videoFragment;
        if (AndroidUtils.hasAPI(18)) {
            videoFragment = new VideoHandlerFragmentAPI18();
        } else {
            videoFragment = new VideoHandlerFragment();
        }

        volControl = new CallVolumeCtrlFragment();

        /**
         * Adds fragment that turns on and off the screen when proximity
         * sensor detects FAR/NEAR distance.
         */
        getSupportFragmentManager().beginTransaction().add(volControl, VOLUME_CTRL_TAG)
                .add(new ProximitySensorFragment(), PROXIMITY_FRAGMENT_TAG)
                /* Adds the fragment that handles video display logic */
                .add(videoFragment, VIDEO_FRAGMENT_TAG)
                /* Adds the fragment that handles call duration logic */
                .add(new CallTimerFragment(), TIMER_FRAGMENT_TAG).commit();
    } else {
        FragmentManager fragmentManager = getSupportFragmentManager();

        // Retrieve restored auto hide fragment
        autoHide = (AutoHideController) fragmentManager.findFragmentByTag(AUTO_HIDE_TAG);

        volControl = (CallVolumeCtrlFragment) fragmentManager.findFragmentByTag(VOLUME_CTRL_TAG);
    }
}

From source file:com.juick.android.ThreadActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    JuickAdvancedApplication.maybeEnableAcceleration(this);
    JuickAdvancedApplication.setupTheme(this);
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    //getSherlock().requestFeature(Window.FEATURE_NO_TITLE);
    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    super.onCreate(savedInstanceState);
    handler = new Handler();

    Intent i = getIntent();//from  w  ww  . j av  a 2 s. co m
    mid = (MessageID) i.getSerializableExtra("mid");
    if (mid == null) {
        finish();
    }

    messagesSource = (MessagesSource) i.getSerializableExtra("messagesSource");
    if (sp.getBoolean("fullScreenThread", false)) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    }
    setContentView(R.layout.thread);
    /*
            findViewById(R.id.gotoMain).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        startActivity(new Intent(ThreadActivity.this, MainActivity.class));
    }
            });
    */
    final View buttons = findViewById(R.id.buttons);
    bSend = (ImageButton) findViewById(R.id.buttonSend);
    bSend.setOnClickListener(this);
    bAttach = (ImageButton) findViewById(R.id.buttonAttachment);
    bAttach.setOnClickListener(this);
    etMessage = (EditText) findViewById(R.id.editMessage);

    if (sp.getBoolean("helvNueFonts", false)) {
        etMessage.setTypeface(JuickAdvancedApplication.helvNue);
        /*
                    TextView oldTitle = (TextView)findViewById(R.id.old_title);
                    oldTitle.setTypeface(JuickAdvancedApplication.helvNue);
        */
    }

    Button cancel = (Button) findViewById(R.id.buttonCancel);
    cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            doCancel();
        }
    });

    tvReplyTo = (TextView) findViewById(R.id.textReplyTo);
    replyToContainer = (RelativeLayout) findViewById(R.id.replyToContainer);
    setHeight(replyToContainer, 0);
    showThread = (Button) findViewById(R.id.showThread);
    draftsButton = (Button) findViewById(R.id.drafts);
    etMessage.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                etMessage.setHint("");
                setHeight(buttons, ActionBar.LayoutParams.WRAP_CONTENT);
                InputMethodManager inputMgr = (InputMethodManager) getSystemService(
                        Context.INPUT_METHOD_SERVICE);
                inputMgr.toggleSoftInput(0, 0);
            } else {
                etMessage.setHint(R.string.ClickToReply);
                setHeight(buttons, 0);
            }
            //To change body of implemented methods use File | Settings | File Templates.
        }
    });
    draftsButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            class Item {
                String label;
                long ts;
                int index;

                Item(String label, long ts, int index) {
                    this.label = label;
                    this.ts = ts;
                    this.index = index;
                }
            }
            final ArrayList<Item> items = new ArrayList<Item>();
            final SharedPreferences drafts = getSharedPreferences("drafts", MODE_PRIVATE);
            for (int q = 0; q < 1000; q++) {
                String msg = drafts.getString("message" + q, null);
                if (msg != null) {
                    if (msg.length() > 50)
                        msg = msg.substring(0, 50);
                    items.add(new Item(msg, drafts.getLong("timestamp" + q, 0), q));
                }
            }
            Collections.sort(items, new Comparator<Item>() {
                @Override
                public int compare(Item item, Item item2) {
                    final long l = item2.ts - item.ts;
                    return l == 0 ? 0 : l > 0 ? 1 : -1;
                }
            });
            CharSequence[] arr = new CharSequence[items.size()];
            for (int i1 = 0; i1 < items.size(); i1++) {
                Item item = items.get(i1);
                arr[i1] = item.label;
            }
            new AlertDialog.Builder(ThreadActivity.this).setItems(arr, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, final int which) {
                    final Runnable doPull = new Runnable() {
                        @Override
                        public void run() {
                            pullDraft(null, drafts, items.get(which).index);
                            updateDraftsButton();
                        }
                    };
                    if (pulledDraft != null
                            && pulledDraft.trim().equals(etMessage.getText().toString().trim())) {
                        // no need to ask, user just looks at the drafts
                        saveDraft(pulledDraftRid, pulledDraftMid, pulledDraftTs, pulledDraft);
                        doPull.run();
                    } else {
                        if (etMessage.getText().toString().length() > 0) {
                            new AlertDialog.Builder(ThreadActivity.this)
                                    .setTitle(getString(R.string.ReplacingText))
                                    .setMessage(getString(R.string.YourTextWillBeReplaced))
                                    .setNegativeButton(android.R.string.ok,
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialog, int which) {
                                                    doPull.run();
                                                }

                                            })
                                    .setNeutralButton(
                                            getString(pulledDraft != null ? R.string.SaveChangedDraft
                                                    : R.string.SaveDraft),
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialog, int which) {
                                                    if (pulledDraft != null) {
                                                        saveDraft(pulledDraftRid, pulledDraftMid,
                                                                System.currentTimeMillis(),
                                                                etMessage.getText().toString());
                                                    } else {
                                                        saveDraft(rid, mid.toString(),
                                                                System.currentTimeMillis(),
                                                                etMessage.getText().toString());
                                                    }
                                                    doPull.run();
                                                }
                                            })
                                    .setPositiveButton(android.R.string.cancel,
                                            new DialogInterface.OnClickListener() {
                                                @Override
                                                public void onClick(DialogInterface dialog, int which) {
                                                }
                                            })
                                    .show();
                        } else {
                            doPull.run();
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            }).show();
        }
    });
    enableDrafts = (sp.getBoolean("enableDrafts", false));
    if (sp.getBoolean("capitalizeReplies", false)) {
        etMessage.setInputType(etMessage.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
    }
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    tf = new ThreadFragment();
    tf.init(getLastCustomNonConfigurationInstance(), this);
    Bundle args = new Bundle();
    args.putSerializable("mid", mid);
    args.putSerializable("messagesSource", messagesSource);
    args.putSerializable("prefetched", i.getSerializableExtra("prefetched"));
    args.putSerializable("originalMessage", i.getSerializableExtra("originalMessage"));
    args.putBoolean("scrollToBottom", i.getBooleanExtra("scrollToBottom", false));
    tf.setArguments(args);
    ft.add(R.id.threadfragment, tf);
    ft.commit();
    MainActivity.restyleChildrenOrWidget(getWindow().getDecorView());
    detector = new GestureDetector(this, new GestureDetector.OnGestureListener() {
        @Override
        public boolean onDown(MotionEvent e) {
            return false;
        }

        @Override
        public void onShowPress(MotionEvent e) {

        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        @Override
        public void onLongPress(MotionEvent e) {

        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (velocityX > 0 && Math.abs(velocityX) > 4 * Math.abs(velocityY) && Math.abs(velocityX) > 400) {
                if (etMessage.getText().toString().trim().length() == 0) {
                    System.out.println("velocityX=" + velocityX + " velocityY" + velocityY);
                    if (sp.getBoolean("swipeToClose", true)) {
                        onBackPressed();
                    }
                }
            }
            return false;
        }
    });

    com.actionbarsherlock.app.ActionBar actionBar = getSherlock().getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setLogo(R.drawable.back_button);

}

From source file:SwipeListViewTouchListener.java

/**
 * Set current item's back view// www.  j  ava2 s  .c  o  m
 *
 * @param backView
 */
private void setBackView(View backView) {
    this.backView = backView;
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickBackView(downPosition);
        }
    });
}

From source file:net.ustyugov.jtalk.activity.vcard.VCardActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    service = JTalkService.getInstance();
    account = getIntent().getStringExtra("account");
    jid = getIntent().getStringExtra("jid");
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);
    setContentView(R.layout.paged_activity);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle("vCard");
    getActionBar().setSubtitle(jid);//w  w  w.  j a  v  a 2  s.  com

    if (service.getConferencesHash(account).containsKey(StringUtils.parseBareAddress(jid))) {
        Presence p = service.getConferencesHash(account).get(StringUtils.parseBareAddress(jid))
                .getOccupantPresence(jid);
        if (p != null) {
            MUCUser mucUser = (MUCUser) p.getExtension("x", "http://jabber.org/protocol/muc#user");
            if (mucUser != null) {
                String j = mucUser.getItem().getJid();
                if (j != null && j.length() > 3)
                    getActionBar().setSubtitle(j);
            }
        }
    }

    LinearLayout linear = (LinearLayout) findViewById(R.id.linear);
    linear.setBackgroundColor(Colors.BACKGROUND);

    LayoutInflater inflater = LayoutInflater.from(this);
    View aboutPage = inflater.inflate(R.layout.vcard_about, null);
    View homePage = inflater.inflate(R.layout.vcard_home, null);
    View workPage = inflater.inflate(R.layout.vcard_work, null);
    View avatarPage = inflater.inflate(R.layout.vcard_avatar, null);
    View statusPage = inflater.inflate(R.layout.list_activity, null);

    first = (MyTextView) aboutPage.findViewById(R.id.firstname);
    middle = (MyTextView) aboutPage.findViewById(R.id.middlename);
    last = (MyTextView) aboutPage.findViewById(R.id.lastname);
    nick = (MyTextView) aboutPage.findViewById(R.id.nickname);
    bday = (MyTextView) aboutPage.findViewById(R.id.bday);
    url = (MyTextView) aboutPage.findViewById(R.id.url);
    about = (MyTextView) aboutPage.findViewById(R.id.desc);

    ctry = (MyTextView) homePage.findViewById(R.id.ctry);
    locality = (MyTextView) homePage.findViewById(R.id.locality);
    street = (MyTextView) homePage.findViewById(R.id.street);
    emailHome = (MyTextView) homePage.findViewById(R.id.homemail);
    phoneHome = (MyTextView) homePage.findViewById(R.id.homephone);

    org = (MyTextView) workPage.findViewById(R.id.org);
    unit = (MyTextView) workPage.findViewById(R.id.unit);
    role = (MyTextView) workPage.findViewById(R.id.role);
    emailWork = (MyTextView) workPage.findViewById(R.id.workmail);
    phoneWork = (MyTextView) workPage.findViewById(R.id.workphone);

    av = (ImageView) avatarPage.findViewById(R.id.av);
    av.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            File file = new File(Constants.PATH + jid.replaceAll("/", "%"));
            Uri uri = Uri.fromFile(file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(uri, "image/*");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException ignored) {
            }
        }
    });

    av.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            String fname = Constants.PATH + jid.replaceAll("/", "%");
            String saveto = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Avatars/";

            File folder = new File(saveto);
            folder.mkdirs();

            try {
                FileInputStream fis = new FileInputStream(fname);
                byte[] buffer = new byte[fis.available()];
                fis.read(buffer);
                fis.close();

                FileOutputStream fos = new FileOutputStream(saveto + "/" + jid.replaceAll("/", "%") + ".png");
                fos.write(buffer);
                fos.close();
                Toast.makeText(VCardActivity.this, "Copied to " + saveto, Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Toast.makeText(VCardActivity.this, "Failed to copy", Toast.LENGTH_LONG).show();
            }
            return true;
        }
    });

    statusProgress = (ProgressBar) statusPage.findViewById(R.id.progress);
    aboutProgress = (ProgressBar) aboutPage.findViewById(R.id.progress);
    homeProgress = (ProgressBar) homePage.findViewById(R.id.progress);
    workProgress = (ProgressBar) workPage.findViewById(R.id.progress);
    avatarProgress = (ProgressBar) avatarPage.findViewById(R.id.progress);

    aboutScroll = (ScrollView) aboutPage.findViewById(R.id.scroll);
    homeScroll = (ScrollView) homePage.findViewById(R.id.scroll);
    workScroll = (ScrollView) workPage.findViewById(R.id.scroll);
    avatarScroll = (ScrollView) avatarPage.findViewById(R.id.scroll);

    list = (ListView) statusPage.findViewById(R.id.list);
    list.setDividerHeight(0);
    list.setCacheColorHint(0x00000000);

    aboutPage.setTag(getString(R.string.About));
    homePage.setTag(getString(R.string.Home));
    workPage.setTag(getString(R.string.Work));
    avatarPage.setTag(getString(R.string.Photo));
    statusPage.setTag(getString(R.string.Status));

    ArrayList<View> mPages = new ArrayList<View>();
    mPages.add(aboutPage);
    mPages.add(homePage);
    mPages.add(workPage);
    mPages.add(avatarPage);
    mPages.add(statusPage);

    MainPageAdapter adapter = new MainPageAdapter(mPages);
    ViewPager mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(adapter);
    mPager.setCurrentItem(0);

    TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
    mTitleIndicator.setTextColor(0xFF555555);
    mTitleIndicator.setViewPager(mPager);
    mTitleIndicator.setCurrentItem(0);

    new LoadTask().execute();
}

From source file:net.wespot.pim.view.InqCreateInquiryFragment.java

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

    wm_title = (EditText) rootView.findViewById(R.id.wonder_moment_title);
    wm_content = (EditText) rootView.findViewById(R.id.wonder_moment_content);

    wm_date = (EditText) rootView.findViewById(R.id.wonder_moment_date);
    wm_time = (EditText) rootView.findViewById(R.id.wonder_moment_time);
    //        wm_location = (EditText) rootView.findViewById(R.id.wonder_moment_location);
    //        wm_clear = (ImageView) rootView.findViewById(R.id.wonder_moment_clear);
    //        wm_progress_bar = (ProgressBar) rootView.findViewById(R.id.wonder_moment_progress_location);
    wm_membership_open = (RadioButton) rootView.findViewById(R.id.wonder_moment_membership_open);
    wm_membership_closed = (RadioButton) rootView.findViewById(R.id.wonder_moment_membership_closed);
    //        wm_visibility = (Spinner) rootView.findViewById(R.id.wonder_moment_visibility);

    wm_visibility = (Spinner) rootView.findViewById(R.id.wonder_moment_visibility);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
            R.array.wonder_moment_visibility_array, R.layout.custom_spinner);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(R.layout.custom_spinner);
    // Apply the adapter to the spinner
    wm_visibility.setAdapter(adapter);// www. j a  v  a  2 s . co  m

    //        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {

    //            if (!(Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1)) {
    //                if (!(Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)){
    //                    getActionBar().setTitle(getResources().getString(R.string.actionbar_list_data_collection_task));
    //                }
    //            }

    //            wm_save =   (ImageButton) rootView.findViewById(R.id.wonder_moment_save);
    //            wm_cancel =   (ImageButton) rootView.findViewById(R.id.wonder_moment_cancel);
    //            wm_save.setImageDrawable(getResources().getDrawable(R.drawable.ic_content_save_black));
    //            wm_cancel.setImageDrawable(getResources().getDrawable(R.drawable.ic_navigation_cancel_black));
    //            wm_save.setOnClickListener(new View.OnClickListener() {
    //                @Override
    //                public void onClick(View view) {
    //                    save_inquiry();
    //                }
    //            });

    //            wm_cancel.setOnClickListener(new View.OnClickListener() {
    //                @Override
    //                public void onClick(View view) {
    //                    getActivity().onBackPressed();
    //                }
    //            });
    //        }else {
    wm_membership_open.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TEMP_MEMBERSHIP = InquiryClient.OPEN_MEMBERSHIP;
        }
    });

    wm_membership_closed.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TEMP_MEMBERSHIP = InquiryClient.CLOSED_MEMBERSHIP;
        }
    });

    //        }

    setDataTime();

    //        wm_clear.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View view) {
    //                Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    //                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    //                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.ENGLISH.toString());
    //                intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getResources().getString(R.string.inquiry_create_voice_recognition));
    //                startActivityForResult(intent, REQUEST_CODE);
    //            }
    //        });

    // Disable button_old if no recognition service is present
    //        PackageManager pm = getActivity().getPackageManager();
    //        List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
    //        if (activities.size() == 0) {
    //            Toast.makeText(getActivity(), "Recognizer Not Found", 1000).show();
    //        }

    // Create inquiry
    new_inquiry = new InquiryLocalObject();

    return rootView;
}