@Override
 public void setOnItemLongClickListener(OnItemLongClickListener listener) {
   onItemLongClickListenerDelegate = listener;
   if (listener == null) {
     super.setOnItemLongClickListener(null);
   } else {
     super.setOnItemLongClickListener(onItemLongClickListenerWrapper);
   }
 }
Exemplo n.º 2
0
  // Event of Long Click
  private void registerLongClickCallback() {
    ListView list = (ListView) findViewById(R.id.listViewWorkouts);
    list.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {

            // needs the event of long clicking the + by accident
            Workouts clickedCar = myWorkouts.get(pos);
            if (clickedCar.getExercise() == "+") {
              workoutToEdit = "";
              startActivity(new Intent(MainActivity.this, EditPage.class));

            } else {
              // Workouts clickedCar = myWorkouts.get(pos);
              Cursor cursorOfWorkout = myDb.getRow(clickedCar.getID());
              workoutToEdit = cursorOfWorkout.getString(DBAdapter.COL_NAME_WORKOUT);
              rowIDLong = cursorOfWorkout.getLong(DBAdapter.COL_ROWID_WORKOUT);
              startActivity(new Intent(MainActivity.this, EditWorkout.class));
            }

            return true;
          }
        });
  }
  private void setUpListView() {
    ListView listView = this.getListView();
    listView.setAdapter(getCommentAdapter());

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mActionMode == null) {
              Comment comment = (Comment) getCommentAdapter().getItem(position);
              mOnCommentSelectedListener.onCommentSelected(comment.commentID);
              getListView().invalidateViews();
            } else {
              getCommentAdapter().toggleItemSelected(position, view);
            }
          }
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // enable CAB if it's not already enabled
            if (mActionMode == null) {
              if (getActivity() instanceof WPActionBarActivity) {
                ((WPActionBarActivity) getActivity()).startActionMode(new ActionModeCallback());
                getCommentAdapter().setEnableSelection(true);
                getCommentAdapter().setItemSelected(position, true, view);
              }
            } else {
              getCommentAdapter().toggleItemSelected(position, view);
            }
            return true;
          }
        });
  }
Exemplo n.º 4
0
  // ListView初始化方法
  private void initListView() {
    // prepareAdapter =
    // AdapterFactory.getAdapterFactory().createMakePrepareAdapter(getActivity(),prepareDataList);
    prepareAdapter = new MakePrepareAdapter(getActivity(), prepareDataList);
    prepareList.setAdapter(prepareAdapter);
    prepareList.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // 显示操作Menu
            // showPopupMenuLocal(view, position, id);
            return true;
          }
        });
    prepareList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // 跳转至采集信息页面
            gotoCollectPrepareFragment(prepareDataList.get(position));
            // hideKeyboard(searchEditText);
          }
        });
  }
Exemplo n.º 5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.city_listview);

    // Receive the data passed from MainActivity
    Bundle params = getIntent().getExtras();

    this.setTitle("Choose a city to load from:");

    // Construct the cities list
    Vector<String> items = new Vector<String>();
    items.add("<Delete City>");

    List<Profile> allCities = db.getAllProfiles();
    for (int i = 0; i < allCities.size(); i++) {
      items.add((allCities.get(i)).cityName);
    }

    cityList = (ListView) findViewById(R.id.list);
    cityList.setOnItemClickListener(this);
    cityList.setOnItemLongClickListener(this);
    cities =
        new ArrayAdapter<String>(
            this, android.R.layout.simple_list_item_1, items.toArray(new String[0]));
    cityList.setAdapter(cities);

    // get the mainProfile from MainActivity
    newProfile = (Profile) params.getParcelableArrayList("profile").get(0);
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Utils.Log("MessageFragment onCreateView called");
    View view = inflater.inflate(R.layout.fragment_messages, container, false);
    messageList = (ListView) view.findViewById(R.id.messages_list);
    messages = dbManager.getMessages(conversation.getUsername());
    adapter =
        new MessagesAdapter(
            getActivity(),
            messages,
            dbManager.getUsername(),
            conversation.getUsername(),
            conversationPass);
    messageList.setAdapter(adapter);

    messageList.setOnItemLongClickListener(messageLongClicked);

    if (savedInstanceState == null) {
      messageList.setSelection(adapter.getCount() - 6);
    }

    sendMessage = (Button) view.findViewById(R.id.btn_message_send);
    sendMessage.setOnClickListener(sendClicked);
    messageText = (MaterialEditText) view.findViewById(R.id.user_message_text);
    return view;
  }
Exemplo n.º 7
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   getWindow().setBackgroundDrawable(null);
   dbHandler = new MyDBHandler(this, null);
   // Use a list to store the inventory
   inventory = new ArrayList<>();
   // fill the list with the inventory from the database
   populateList();
   // set the listview UI element's data to inventory list
   adapter = new ArrayAdapter<String>(this, R.layout.list_item_inventory, R.id.item, inventory);
   inventoryListView = (ListView) findViewById(R.id.list_view_inventory);
   inventoryListView.setAdapter(adapter);
   // register on item click listeners for the listview
   inventoryListView.setOnItemClickListener(this);
   inventoryListView.setOnItemLongClickListener(this);
   // register click listener on the fab
   fab = (FloatingActionButton) findViewById(R.id.fab);
   fab.setOnClickListener(this);
   // tell the user what to do
   Toast.makeText(this, "Tap item to subtract 1, hold to update or delete", Toast.LENGTH_LONG)
       .show();
   createAds();
 }
Exemplo n.º 8
0
  @Override
  protected void postInitUI() {
    super.postInitUI();
    mAdapter = new AlarmListAdapter(this);
    mAdapter.setCache(controller.getCache());
    controller.addObserver(mAdapter);
    mAdapter.setClockAction(controller);
    lvAlarm.setAdapter(mAdapter);
    lvAlarm.setOnItemClickListener(
        new OnItemClickListener() {

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

            Log.d(Clock.TAG, "default click");
            TemporaryData.save(Clock.class.getName(), controller.getCache().read().get(position));
            TemporaryData.save(ClockController.class.getName(), controller);
            AlarmEditActivity.callMe(AlarmListActivity.this);
          }
        });
    lvAlarm.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            showDialog(controller.getCache().read().get(position));
            return true;
          }
        });
    controller.checkDefaultClockPolicy();
  }
Exemplo n.º 9
0
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   context = this;
   lvListView = getListView();
   lvListView.setOnItemLongClickListener(this);
   refreshList();
 }
Exemplo n.º 10
0
 @Override
 public void dataReadyListener(List<IProfileModel> models) {
   mProfiles.addAll(models);
   mAdapter.notifyDataSetChanged();
   mProfileList.setOnItemClickListener(mProfileListItemClickListener);
   mProfileList.setOnItemLongClickListener(mProfileLongClickListener);
 }
Exemplo n.º 11
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    listview = new ListView(this.getActivity());

    listview.setBackgroundResource(ThemeManager.getInstance().getBackgroundColor());
    listview.setDivider(null);

    activeActionMode();
    listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listview.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @TargetApi(11)
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            ListView lv = (ListView) parent;
            lv.setItemChecked(position, true);
            if (mActionModeCallback != null) {
              ((ActionBarActivity) getActivity())
                  .startSupportActionMode((Callback) mActionModeCallback);
              return true;
            }
            return false;
          }
        });

    listview.setDescendantFocusability(ListView.FOCUS_AFTER_DESCENDANTS);

    return listview;
  }
Exemplo n.º 12
0
  private void initView() {
    listview = (ListView) findViewById(R.id.list);
    listview.setOnItemClickListener(this);
    listview.setOnItemLongClickListener(this);
    adapter =
        new MessageRecentAdapter(
            getActivity(), R.layout.item_conversation, BmobDB.create(getActivity()).queryRecents());
    listview.setAdapter(adapter);

    mClearEditText = (ClearEditText) findViewById(R.id.et_msg_search);
    mClearEditText.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s);
          }

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

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
Exemplo n.º 13
0
  private void initWidgets() {

    mListView = (ListView) view.findViewById(R.id.left_listview);

    myAdapter = new MyAdapter();
    mListView.setAdapter(myAdapter);
    mListView.setOnItemClickListener(this);
    mListView.setOnItemLongClickListener(this);

    myAdapter.setSelectPosition(0);

    addUserButton = (RelativeLayout) view.findViewById(R.id.left_button_add_user);
    addUserButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub

            mDataManager.getUserListControlListener().onUserListDismiss();
            Intent jumbIntent = new Intent();
            jumbIntent.setClass(getActivity(), LoginActivity.class);
            getActivity().startActivityForResult(jumbIntent, START_ACTIVITY_LOGIN);
          }
        });
  }
Exemplo n.º 14
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE) logger.warn("{} onCreateView()", fullName);
    View v = inflater.inflate(R.layout.chatview_main, container, false);

    uiLines = (ListView) v.findViewById(R.id.chatview_lines);
    uiInput = (EditText) v.findViewById(R.id.chatview_input);
    uiSend = (ImageButton) v.findViewById(R.id.chatview_send);
    uiTab = (ImageButton) v.findViewById(R.id.chatview_tab);

    uiSend.setOnClickListener(this);
    uiTab.setOnClickListener(this);
    uiInput.setOnKeyListener(this); // listen for hardware keyboard
    uiInput.addTextChangedListener(
        this); // listen for software keyboard through watching input box text
    uiInput.setOnEditorActionListener(
        this); // listen for software keyboard's “send” click. see onEditorAction()

    uiLines.setFocusable(false);
    uiLines.setFocusableInTouchMode(false);

    CopyPaste cp = new CopyPaste(activity, uiInput);
    uiInput.setOnLongClickListener(cp);
    uiLines.setOnItemLongClickListener(cp);

    return v;
  }
Exemplo n.º 15
0
  /** Called when the activity is first created */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "LoaderActivity created");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.content);

    // Instantiate custom adapter
    mAdapter = new LoaderAdapter();

    // Handle listview and assign adapter
    mListView = (ListView) findViewById(R.id.content_list_view);
    mListView.setAdapter(mAdapter);
    mListView.setVisibility(View.GONE);
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
            selectItem(position);
            return true;
          }
        });

    mStatusLabel = (TextView) findViewById(R.id.content_status_label);
    mStatusLabel.setVisibility(View.VISIBLE);

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) showUserHashDialog();
    else refreshMapList();
  }
  private void bindClientList() {
    List<Client> clients = getClients();
    listViewClients = (ListView) findViewById(R.id.listViewClients);
    final ClientListAdapter clientAdapter = new ClientListAdapter(ClientListAcitvity.this, clients);
    listViewClients.setAdapter(clientAdapter);

    listViewClients.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            client = (Client) parent.getItemAtPosition(position);
            return false;
          }
        });
    listViewClients.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Client client = (Client) parent.getItemAtPosition(position);
            // Best Practices:
            // http://stackoverflow.com/questions/4275678/how-to-make-phone-call-using-intent-in-android
            final Intent goToSOPhoneCall =
                new Intent(
                    Intent.ACTION_CALL /* or Intent.ACTION_DIAL (no manifest permission needed) */);
            goToSOPhoneCall.setData(Uri.parse("tel:" + client.getPhone()));
            startActivity(goToSOPhoneCall);
          }
        });
    registerForContextMenu(listViewClients);
  }
  private void initListView() {
    ListView listView = (ListView) this.findViewById(R.id.favouritesListView);

    final Activity parentActivity = this;

    listView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          /* (non-Javadoc)
           * @see android.widget.AdapterView.OnItemLongClickListener#onItemLongClick(android.widget.AdapterView, android.view.View, int, long)
           */
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            selectedFavourite = (Favourite) parent.getItemAtPosition(position);

            return false;
          }
        });
    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Favourite favourite = (Favourite) parent.getItemAtPosition(position);

            WallpaperPreviewActivity.showPreviewActivity(parentActivity, favourite.getWallpaper());
          }
        });

    this.registerForContextMenu(listView);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_zen, null);

    progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
    progressBar.setProgress(0);
    progressBar.setVisibility(View.INVISIBLE);

    liview = (ListView) v.findViewById(R.id.listView);
    liview.setAdapter(mAdapter);
    liview.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            if (mActionMode != null) {
              return false;
            }
            mPosition = position;
            // Start the CAB using the ActionMode.Callback defined above
            mActionMode = getActivity().startActionMode(mActionModeCallback);
            view.setSelected(true);
            return true;
          }
        });
    return v;
  }
Exemplo n.º 19
0
  private void setupListViewListener() {
    lvItems.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> adapter, View item, int pos, long id) {
            items.remove(pos);
            itemsAdapter.notifyDataSetChanged();
            writeItems();
            return true;
          }
        });

    lvItems.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> adapter, View item, int pos, long id) {

            Intent i = new Intent(MainActivity.this, EditItemActivity.class);
            i.putExtra("position", pos);
            i.putExtra("id", id);
            i.putExtra("item", items.get(pos));
            startActivityForResult(i, REQUEST_CODE);
          }
        });
  }
Exemplo n.º 20
0
  private void setupIndex(TropesIndex index) {
    ArrayAdapter<TropesLink> tropeAdapter =
        new ArrayAdapter<TropesLink>(
            getActivity(), android.R.layout.simple_list_item_1, index.tropes);
    ListView lv = (ListView) getActivity().findViewById(R.id.lv_tropes);
    lv.setAdapter(tropeAdapter);

    lv.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            TropesLink item = (TropesLink) parent.getItemAtPosition(position);
            interactionListener.onLinkClicked(item.url);
          }
        });

    lv.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            TropesLink link = (TropesLink) parent.getItemAtPosition(position);
            interactionListener.onLinkSelected(link.url);
            return true;
          }
        });

    articleInfo = new TropesArticleInfo(index.title, index.url, index.subpages);
  }
Exemplo n.º 21
0
  private void fill(File[] files) {
    this.directoryEntries.clear();

    if (this.currentDirectory.getParent() != null) {
      this.directoryEntries.add(UP_ONE_LEVEL_DIR);
    }
    switch (this.displayMode) {
      case ABSOLUTE:
        for (File file : files) {
          this.directoryEntries.add(file.getPath());
        }
        break;
      case RELATIVE:
        int currentPathStringLength = this.currentDirectory.getAbsolutePath().length();
        for (File file : files) {
          if (file.isDirectory()) {
            this.directoryEntries.add(
                file.getAbsolutePath().substring(currentPathStringLength) + "/");
          } else {
            for (String fileExtension : fileExtensions) {
              if (file.getName().toLowerCase().endsWith(fileExtension.toLowerCase())) {
                this.directoryEntries.add(
                    file.getAbsolutePath().substring(currentPathStringLength));
              }
            }
          }
        }
    }

    FileBrowserAdapter directoryList =
        new FileBrowserAdapter(mActivity, R.layout.filebrowser_item, directoryEntries);
    fbListView.setAdapter(directoryList);
    fbListView.setOnItemClickListener(this);
    fbListView.setOnItemLongClickListener(this);
  }
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // add data to ListView
    for (int i = 0, count = 20; i < count; i++) {
      mDataSourceList.add("列表数据" + i);
    }

    ArrayList<User> arUser;
    arUser = new ArrayList<User>();
    User user;

    user = new User("1", "pppgod", "이상윤");
    arUser.add(user);
    user = new User("2", "dodo3371", "김정은");
    arUser.add(user);

    UserAdapter adapter = new UserAdapter(getActivity(), R.layout.custom_rank_list, arUser);

    ListView list;
    list = (ListView) getActivity().findViewById(R.id.list_all);
    list.setAdapter(adapter);
    list.setDividerHeight(2);

    list.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(getActivity(), UserInfoActivity.class);
            startActivity(intent);
            return false;
          }
        });
  }
  private static <LI extends ListItem> void fillListView(
      @Nonnull final ListView lv,
      @Nonnull final ListItemAdapter<? extends LI> adapter,
      @Nonnull final Context context) {
    lv.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final ListItem listItem = (ListItem) lv.getItemAtPosition(position);
            ListItem.OnClickAction onClickAction = listItem.getOnClickAction();
            if (onClickAction != null) {
              onClickAction.onClick(context, adapter, lv);
            }
          }
        });

    lv.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final ListItem listItem = (ListItem) lv.getItemAtPosition(position);
            ListItem.OnClickAction onLongClickAction = listItem.getOnLongClickAction();
            if (onLongClickAction != null) {
              onLongClickAction.onClick(context, adapter, lv);
              return true;
            } else {
              return false;
            }
          }
        });
  }
Exemplo n.º 24
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE) logger.debug("onCreateView()");
    View v = inflater.inflate(R.layout.chatview_main, container, false);

    uiLines = (ListView) v.findViewById(R.id.chatview_lines);
    uiInput = (EditText) v.findViewById(R.id.chatview_input);
    uiSend = (ImageButton) v.findViewById(R.id.chatview_send);
    uiTab = (ImageButton) v.findViewById(R.id.chatview_tab);

    uiSend.setOnClickListener(this);
    uiTab.setOnClickListener(this);
    uiInput.setOnKeyListener(this); // listen for hardware keyboard
    uiInput.addTextChangedListener(
        this); // listen for software keyboard through watching input box text
    uiInput.setOnEditorActionListener(
        this); // listen for software keyboard's “send” click. see onEditorAction()

    uiLines.setFocusable(false);
    uiLines.setFocusableInTouchMode(false);

    CopyPaste cp = new CopyPaste(activity, uiInput);
    uiInput.setOnLongClickListener(cp);
    uiLines.setOnItemLongClickListener(cp);

    uiMore = (ViewGroup) inflater.inflate(R.layout.more_button, null);
    uiMoreButton = (Button) uiMore.findViewById(R.id.button_more);
    uiMoreButton.setOnClickListener(this);
    uiLines.addHeaderView(uiMore);
    status = Buffer.LINES.CAN_FETCH_MORE;

    online = true;
    return v;
  }
Exemplo n.º 25
0
  private void renderList() {
    String fList = settings.filterList();
    String[] arr = {};
    if (fList.length() > 0) {
      arr = fList.split(",");
    }
    ArrayList<String> list = new ArrayList<String>();
    for (Integer i = 0; i < arr.length; i++) {
      list.add(arr[i]);
    }
    ListView lv = (ListView) findViewById(R.id.number_list);
    final NumberListAdapter adapter = new NumberListAdapter(this, list);
    lv.setAdapter(adapter);

    lv.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            String num = (String) adapter.getItem(position);
            settings.filterDel(num);
            renderList();
            return true;
          }
        });
  }
Exemplo n.º 26
0
  private ListView getListView() {
    if (mListView == null) {
      mListView = (ListView) findViewById(android.R.id.list);

      // enable replying to an individual comment when the user long clicks it - this is done
      // instead of setting an OnItemClickListener for two reasons:
      //   1. OnItemClickListener won't fire for comments that contain links (due
      //      to the comment text using autoLink="web")
      //   2. It's too easy to accidentally cause OnItemClickListener to fire while
      //      scrolling/flinging through the list, whereas OnItemLongClickListener
      //      is a more deliberate action
      mListView.setOnItemLongClickListener(
          new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(
                AdapterView<?> parent, View view, int position, long id) {
              // id will be the id of the tapped comment - note that it will be -1 when the
              // post detail header is long clicked, which we want to ignore
              if (id != 0 && id != -1) {
                showAddCommentBox(id);
                return true;
              } else {
                return false;
              }
            }
          });
    }
    return mListView;
  }
Exemplo n.º 27
0
  // SearchListView初始化方法
  private void initSearchListView() {
    if (searchItemList == null) {
      searchItemList = new ArrayList();
    }
    showNullItemImg(searchItemList, nullItemLayoutSearch);
    searchAdapter = new MakePrepareAdapter(getActivity(), searchItemList);
    searchList.setAdapter(searchAdapter);
    searchList.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(
                    getActivity(),
                    "LongClick on " + parent.getAdapter().getItemId(position),
                    Toast.LENGTH_SHORT)
                .show();
            return true;
          }
        });
    searchList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // isValidTectChanged = false;
            // 按钮不可用
            btnSearch.setClickable(false);
            // 隐藏键盘
            hideKeyboard(searchEditText);
            // 处理所点击的某一个Item
            disposeSearchListItemClick(position);
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.reorder_list_activity);
    mPackageManager = getPackageManager();
    mResolver = getContentResolver();

    mIntentList = getListView();
    mIntentList.setFastScrollEnabled(true);
    mIntentList.setOnItemLongClickListener(this);

    ((ReorderListView) mIntentList).setDropListener(mDropListener);

    if (mIntentAdapter == null) {
      mIntentAdapter = new IntentAdapter(this);
    }
    setListAdapter(mIntentAdapter);

    Button addButton = (Button) findViewById(R.id.lockscreen_button_add);
    addButton.setOnClickListener(this);
    mClearButton = (Button) findViewById(R.id.lockscreen_button_clear);
    mClearButton.setEnabled(!parseIntents().isEmpty());
    mClearButton.setOnClickListener(this);

    setupActionBar();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.lista_socio_negocio_tab_fragment_lead, container, false);

    sideIndex = (LinearLayout) v.findViewById(R.id.sideIndex);
    lvSN = (ListView) v.findViewById(R.id.lvLstSocioLeadNeg);

    contexto = v.getContext();

    // Obtener el refreshLayout
    refreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipeRefresh);

    // Seteamos los colores que se usar�n a lo largo de la animaci�n
    refreshLayout.setColorSchemeResources(R.color.s1, R.color.s2, R.color.s3, R.color.s4);

    // FLOATING BUTTON
    FloatingActionButton fab = (FloatingActionButton) v.findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            Intent registrarSN = new Intent(v.getContext(), MainSocioNegocio.class);
            startActivity(registrarSN);
          }
        });
    // FLOATING BUTTON

    lvSN.setOnItemLongClickListener(this);
    lvSN.setOnScrollListener(this);
    setHasOptionsMenu(true);
    return v;
  }
  @Override
  public void onActivityCreated(Bundle arg0) {
    myListView = (ListView) getView().findViewById(R.id.myListView);
    progs = new TrainingFactory(getActivity()).getListTrainingProgs();
    ArrayList<String> names = new ArrayList<String>(progs.keySet());
    mAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, names);
    myListView.setAdapter(mAdapter);
    myListView.setOnItemClickListener(
        new OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            editProgram(mAdapter.getItem(arg2));
          }
        });
    myListView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            mCurrPosition = arg2;
            longPressDialog.show();
            return false;
          }
        });

    View btnAdd = getView().findViewById(R.id.buttonAdd);
    btnAdd.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            showNewProgDialog();
          }
        });
    super.onActivityCreated(arg0);
  }