Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    Bundle extras = getIntent().getExtras();

    if (extras != null) idUser = (int) extras.getLong("idUser");

    categoryAdapter = new CategoryListAdapter(this);
    projectAdapter = new ProjectListAdapter(this);

    lvCategories = (ListView) findViewById(R.id.lvCategories);
    lvCategories.setAdapter(categoryAdapter);
    lvCategories.setClickable(true);

    lvProjects = (ListView) findViewById(R.id.lvProjects);
    lvProjects.setAdapter(projectAdapter);
    lvProjects.setClickable(true);

    categoryService = new CategoryService();
    categories = categoryService.getAllCategories();

    for (Category c : categories) categoryAdapter.add(c);

    projectService = new ProjectService();
    projects = projectService.getAllProjects();

    for (Project p : projects) projectAdapter.add(p);

    lvCategories.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            projectAdapter.removeAll();
            projectsByCategory = projectService.getProjectsByCategory(position + 1);
            for (Project p : projectsByCategory) projectAdapter.add(p);
          }
        });

    lvProjects.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent_ListProjectProjectbyId = new Intent(ListProject.this, ProjectbyId.class);
            Intent_ListProjectProjectbyId.putExtra("idProject", position + 1);
            Intent_ListProjectProjectbyId.putExtra("idUser", idUser);
            startActivity(Intent_ListProjectProjectbyId);
          }
        });
  }
Ejemplo n.º 2
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_calllog);

    mListView = (ListView) findViewById(R.id.listview_calllog);
    mListView.setClickable(true);
    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

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

            HashMap<String, Object> data =
                (HashMap<String, Object>) mListView.getItemAtPosition(position);
            String number = data.get(CALLLOG_NUMBER).toString();
            String user = data.get(CALLLOG_USERNAME).toString();

            Log.i(CALLLOGACTIVITY, "Touch " + user + " " + number);
            Bundle bundle = new Bundle();
            bundle.putString(CALLLOG_NUMBER, number);
            bundle.putString(CALLLOG_USERNAME, user);

            Intent intent = new Intent();
            intent.putExtras(bundle);
            CallLogActivity.this.setResult(RESULT_OK, intent);
            CallLogActivity.this.finish();
          }
        });

    updateListviewData();
  }
Ejemplo n.º 3
0
      /** This will be executed in ui thread */
      @Override
      protected void onPostExecute(SimpleAdapter adapter) {

        /** Getting a reference to listview of main.xml layout file */
        final ListView listView = (ListView) findViewById(R.id.venueList);

        listView.setBackgroundColor(Color.rgb(223, 223, 224));

        /** Setting the adapter containing the country list to listview */
        listView.setAdapter(adapter);

        listView.setClickable(true);
        listView.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {

              @Override
              public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                HashMap hm = (HashMap) listView.getItemAtPosition(position);

                selVenueID = hm.get("id").toString();
                selVenueName = hm.get("name").toString();
                selVenueLat = hm.get("lat").toString();
                selVenueLng = hm.get("lng").toString();
                showMovies(listView);
              }
            });
      }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    lv_user = (ListView) findViewById(R.id.listview);
    message = (TextView) findViewById(R.id.message);
    mContext = this;
    addContact = (ImageView) findViewById(R.id.addContact);
    appUserHelper = new UserHelper(mContext);

    LoadUserData();
    if (usersList != null && usersList.size() > 0) {
      adapter = new CustomAdapter(this, R.layout.contact_items, usersList);
      lv_user.setVisibility(View.VISIBLE);
      message.setVisibility(View.GONE);
      lv_user.setAdapter(adapter);
      lv_user.setClickable(true);
      lv_user.setOnItemClickListener(this);
    } else {
      lv_user.setVisibility(View.GONE);
      message.setVisibility(View.VISIBLE);
    }

    addContact.setOnClickListener(this);
  }
Ejemplo n.º 5
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lista);
    //		ProgressDialog show = ProgressDialog.show(ListaAlunos.this, "Aguarde...", "Enviando dados!",
    // true);
    AlunoDAO alunoDAO = new AlunoDAO(this, "Aluno", null, 1);
    List<Aluno> alunos = alunoDAO.getLista();
    alunoDAO.close();

    ArrayAdapter<Aluno> adapterView =
        new ArrayAdapter<Aluno>(this, android.R.layout.simple_list_item_1, alunos);
    ListView listaAlunos = (ListView) findViewById(R.id.listaAlunos);
    Button botaoInserir = (Button) findViewById(R.id.botaoInserir);
    listaAlunos.setAdapter(adapterView);
    listaAlunos.setClickable(true);
    listaAlunos.setLongClickable(true);
    listaAlunos.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> adapter, View view, int posicao, long id) {
            return false;
          }
        });

    registerForContextMenu(listaAlunos);

    listaAlunos.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> adapter, View view, int posicao, long id) {
            SharedPreferences preferences = getSharedPreferences("alunoselecionado", MODE_PRIVATE);
            SharedPreferences.Editor editor = preferences.edit();
            editor.putInt("posicao", posicao);
            editor.commit();

            startActivity(new Intent(ListaAlunos.this, Formulario.class));
          }
        });

    botaoInserir.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            startActivity(new Intent(ListaAlunos.this, Formulario.class));
          }
        });

    Button botaoGaleria = (Button) findViewById(R.id.botaoGaleria);
    botaoGaleria.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            startActivity(new Intent(ListaAlunos.this, Galeria.class));
          }
        });
  }
Ejemplo n.º 6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mpref = this.getSharedPreferences("mypref", 0);
    handler = new Handler();
    bargeStatus = new ArrayList<String>();
    bargeNames = new ArrayList<String>();
    bargeTimes = new ArrayList<String>();
    latList = new ArrayList<Integer>();
    lonList = new ArrayList<Integer>();
    toBargeMap = new Intent(BargeList.this, BargeMap.class);
    bargeList = getListView();
    bargeList.setClickable(true);
    bargeList.setItemsCanFocus(false);

    helpcolor = new Dialog(BargeList.this);
    helpcolor.setContentView(R.layout.helpcolor);
    helpcolor.setTitle("Help");
    Button helpok = (Button) helpcolor.findViewById(R.id.helpok);
    helpok.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            helpcolor.dismiss();
          }
        });
  }
Ejemplo n.º 7
0
  /*
   * display menu
   * */
  public void menu() {
    /*
     * view for list of items for the menu
     */
    final ListView listmenu = (ListView) findViewById(R.id.listmenu);
    String[] listeStrings = {"Play", "Open", "Edit", "Save", "Share Position", "Share DeadHal"};
    listmenu.setClickable(true);
    listmenu.setFocusable(true);
    /*
     * defines actions for every item of the menu
     */
    listmenu.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            if (position == 0) {
              graphicRoom.setEdit(false);
            }
            if (position == 1) {}
            if (position == 2) {
              graphicRoom.setEdit(true);
            }
            if (position == 3) {}
            if (position == 4) {}
            if (position == 5) {}
          }
        });
    int[] colors = {0, Color.WHITE, 0};
    listmenu.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
    listmenu.setDividerHeight(1);
    listmenu.setAdapter(
        new ArrayAdapter<String>(this, R.layout.list_menu, R.id.list_content, listeStrings));
  }
Ejemplo n.º 8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_measures_list);

    app = (MyExApp) getApplication();
    mAdapter = new MeasuresAdapter(app, this, app.getDataManager().getMeasures(null, null));

    // Click on list
    mListView = (ListView) findViewById(android.R.id.list);
    mListView.setEmptyView(findViewById(android.R.id.empty));
    mListView.setClickable(true);
    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {

          public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
            Measure measure = (Measure) mAdapter.getItem(position);
            Intent intent = new Intent(MeasuresActivity.this, MeasuresEditActivity.class);
            intent.putExtra("id", measure.getId());
            startActivityForResult(intent, 0);
          }
        });

    // Fill the list
    mAdapter = new MeasuresAdapter(app, this, app.getDataManager().getMeasures(null, null));
    mListView.setAdapter(mAdapter);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.album_layout);

    // disable the change in the orientation of the activity on rotating the phone
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // initialize the member variables of the class
    artistSongs = (ListView) findViewById(R.id.albumList1);
    backButton = (Button) findViewById(R.id.backButtonAlbum);
    listCaption = (Button) findViewById(R.id.listCaption);
    activity = this;
    songNames = new ArrayList<String>();
    messageToast = new Toast(this);

    // if the user doesn't select any song and returns without selecting a song.
    // this click listener returns RESULT_CANCELLED as the result when the user clicks this button.
    backButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            setResult(Activity.RESULT_CANCELED);
            activity.finish();
          }
        });
    artistSongs.setClickable(true);

    // this click listener sets the song and the artist for the song selected by the user to be
    // returned to the parent activity.
    artistSongs.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            Log.d("SingleArtistListing", "the item selected is " + arg2);
            // TODO Auto-generated method stub

            selectedSong = artistSongs.getAdapter().getItem(arg2).toString();
            Log.d("SingleArtistListing", "The selected song is " + selectedSong);
            resultIntent = new Intent();
            resultIntent.putExtra("songName", selectedSong);
            resultIntent.putExtra("artistName", artistName);
            setResult(Activity.RESULT_OK, resultIntent);
            activity.finish();
          }
        });
    receivedBundle = getIntent().getExtras();
    artistName = receivedBundle.getString("artistName");
    listCaption.setText(receivedBundle.getString("artistName").toUpperCase());
    loadFileSystem();
  }
Ejemplo n.º 10
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_item, container, false);

    rootView = inflater.inflate(R.layout.listfragment, container, false);
    list = (ListView) rootView.findViewById(R.id.listView);
    list.setClickable(true);

    return rootView;
  }
Ejemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event_list);
    db = new WebSyncDB(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(new MyNavigationDrawer(this));

    lv = (ListView) findViewById(R.id.event_list_lv);
    ela = new EventListAdapter(this, R.layout.lay_event_element);
    lv.setAdapter(ela);
    lv.setClickable(false);

    Intent intent = getIntent();
    String code = intent.getStringExtra("event_list");
    Cursor cursor = db.getParticularEvents(code.replaceAll(" ", ""));
    int c = 0;
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
      ela.add(
          new Event(
              cursor.getInt(0),
              cursor.getString(1),
              cursor.getInt(2),
              cursor.getInt(3),
              cursor.getInt(4),
              cursor.getString(5),
              cursor.getString(6)));
      cursor.moveToNext();
      c++;
      if (c > 100) break;
    }
    String title = code;

    getSupportActionBar().setTitle(title);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = super.onCreateView(inflater, container, savedInstanceState);

    ListView listView = (ListView) v.findViewById(R.id.listView);
    listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    listView.setClickable(true);

    listView.setDivider(null);
    listView.setDividerHeight(0);

    listView.setBackgroundColor(getResources().getColor(R.color.grey_lighter));

    return v;
  }
Ejemplo n.º 13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.lista);

    lista = (ListView) findViewById(R.cadastro.listaAlunos);

    lista.setClickable(true);
    lista.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> adapter, View view, int posicao, long id) {
            Toast.makeText(ListaAluno.this, "Posição selecionada: " + posicao, Toast.LENGTH_LONG)
                .show();
            alunoSelecionado = (Aluno) lista.getItemAtPosition(posicao);
            Intent edicao = new Intent(ListaAluno.this, Formulario.class);
            edicao.putExtra("alunoSelecionado", alunoSelecionado);
            startActivity(edicao);
          }
        });

    /*
          lista.setOnItemLongClickListener(new OnItemLongClickListener() {
          	public boolean onItemLongClick(AdapterView<?> adapter, View view,
          			int posicao, long id) {

          		Toast.makeText( ListaAluno.this, "Posição selecionada com o toque mais longo: " + posicao, Toast.LENGTH_LONG).show();

          		return false;
          	}
    });
    */

    lista.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView<?> adapter, View view, int position, long id) {

            alunoSelecionado = (Aluno) adapter.getItemAtPosition(position);

            registerForContextMenu(lista);

            return false;
          }
        });
  }
Ejemplo n.º 14
0
  public void setViewList() {
    listView = (ListView) findViewById(R.id.listView_consumes);
    // 获取数据库的时候应该单独开一条线程  以为是耗时的操作  这个demo数据库简单  我就放在主线程了
    // consumeInfos = consumeDao.getRecordsAsDay(TabList.this,ShowType,day);
    // consumeInfos = consumeDao.getAllRecords(TabChart.this);

    sharedPreferences = getSharedPreferences("config", Context.MODE_PRIVATE);
    long current_user_id = sharedPreferences.getLong("current_user_id", -1);
    consumeDao = ConsumeTb.getConsumeTb(TabChart.this);
    consumeInfos = consumeDao.get_records(30);

    UserTb user_table = UserTb.get_user_tb(TabChart.this);
    ArrayList<UserInfo> user_infos = user_table.get_user_list();

    if (consumeInfos != null && consumeInfos.size() != 0) {
      Toast.makeText(TabChart.this, "消费朋友圈", 0).show();

      // final TagTb tag_tb = TagTb.get_tag_tb(TabChart.this);
      // final ArrayList<TagInfo> tag_infos = tag_tb.get_tags_with_klass(2);
      // listView.setAdapter(new ListViewTagSelectAdapter(tag_infos, TabChart.this));
      listView.setAdapter(
          new ListViewFriendsConsumesAdapter(consumeInfos, user_infos, TabChart.this));
      listView.setClickable(true);
      listView.setOnItemClickListener(
          new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              ConsumeInfo consumeinfo = consumeInfos.get(position);
              // String consume_id = ((TextView)
              // view.findViewById(R.id.consume_id)).getText().toString();

              Toast.makeText(TabChart.this, consumeinfo.get_remark(), 0).show();
              // 界面切换
              // 显示记录记录
              // Intent intent = new Intent(TabChart.this, ConsumeItem.class);
              // intent.putExtra("created_at", created_at);
              // startActivity(intent);
            }
          });
    } else {
      Toast.makeText(TabChart.this, "No Data", 0).show();
    }
    listView.invalidate();
  }
Ejemplo n.º 15
0
  public void createLobby(JSONArray result) {

    listOfRooms = new ArrayList<>();
    roomIds = new HashMap<>();

    try {
      for (int i = 0; i < result.length(); i++) {
        JSONObject newRoom = result.getJSONObject(i);
        LobbyListItem item =
            new LobbyListItem(
                newRoom.getString("name"),
                newRoom.getString("ownerName"),
                newRoom.getInt("owner"),
                newRoom.getInt("maxPlayers"),
                newRoom.getInt("playerCount"),
                (newRoom.getInt("canBreakWall") == 1),
                newRoom.getInt("timeLimit"),
                newRoom.getDouble("maxDist"));
        listOfRooms.add(item);
        roomIds.put(newRoom.getString("name"), newRoom.getInt("id"));
        if (gameToJoin == newRoom.getInt("id")) {
          joinGame(item);
          gameToJoin = -1; // Reset gameToJoin so when we return to lobby we don't join it again
        }
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }

    ListView lobbyList = (ListView) findViewById(R.id.mainList);

    // Store the scroll position
    View view = lobbyList.getChildAt(0);
    int indexPosition = lobbyList.getFirstVisiblePosition();
    int top = (view == null) ? 0 : (view.getTop() - lobbyList.getPaddingTop());

    lobbyList.setClickable(true);
    LobbyCustomAdapter adapter = new LobbyCustomAdapter(this, listOfRooms);
    lobbyList.setAdapter(adapter);

    // Reset the scroll position
    lobbyList.setSelectionFromTop(indexPosition, top);
  }
Ejemplo n.º 16
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.hotels);

    listView = (ListView) findViewById(R.id.hotelsList);
    updateList();

    listView.setClickable(true);
    listView.setOnItemClickListener(
        new OnItemClickListener() {
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

            if (arg2 < list.size()) {
              APIHelper.current_hotel = list.get(arg2);
              Log.w("log", "Click = " + APIHelper.current_hotel.toString());

              Intent i = new Intent(HotelsActivity.this, NewBookingActivity.class);
              startActivity(i);
            }
          }
        });

    // this.setListAdapter(adapter);

    loading = new ProgressDialog(HotelsActivity.this);
    loading.setTitle("Loading...");
    loading.setMessage("Please wait while we're fetching your data.");
    loading.show();

    new Thread(
            new Runnable() {
              public void run() {
                ArrayList<Hotel> list = APIHelper.ListHotels();

                // Create a new Message and post it to the queue!
                Message m = new Message();
                m.obj = list;
                handler.sendMessage(m);
              }
            })
        .start();
  }
Ejemplo n.º 17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user);

    authentication = Authentication.getInstance(getApplicationContext(), FlickrHelper.getFlickr());

    button = (Button) findViewById(R.id.button_login);
    textView = (TextView) findViewById(R.id.text_login);

    ((Button) findViewById(R.id.button_templates))
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), TemplateActivity.class));
              }
            });

    ((Button) findViewById(R.id.button_get_photosets))
        .setOnClickListener(
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                new GetPhotosetsTask().execute();
              }
            });

    photosetsAdapter = new Adapter();
    ListView listView = (ListView) findViewById(R.id.listview_photosets);
    listView.setAdapter(photosetsAdapter);
    listView.setClickable(true);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showPhotoset(photosets.get(position));
          }
        });

    updateState();
  }
Ejemplo n.º 18
0
  /**
   * Sets the view data from a given overlay item.
   *
   * @param item - The overlay item containing the relevant view data (title and line1).
   */
  public void setData(PlacesOverlayItem item) {

    mLayout.setVisibility(VISIBLE);
    if (item.getName() != null) {
      mTitle.setVisibility(VISIBLE);
      mTitle.setText(item.getName());
    } else {
      mTitle.setVisibility(GONE);
    }

    if (item.getVisitTimes() != null) {
      mList.setVisibility(VISIBLE);
      mList.setFocusable(false);
      mList.setClickable(false);
      mList.setSelected(false);
      mList.setFocusableInTouchMode(false);
      mList.setDividerHeight(0);

      VisitTimeAdapter adapter =
          new VisitTimeAdapter(mCxt, R.layout.balloon_overlay_item, item.getVisitTimes());
      mList.setAdapter(adapter);

    } else {
      mList.setVisibility(GONE);
    }

    Drawable drawable = null;

    int type = item.getType();

    if (type == Places.TYPE_GPS) {
      drawable = mCxt.getResources().getDrawable(R.drawable.icon_satellite);
      mIcon.setVisibility(VISIBLE);
      mIcon.setImageDrawable(drawable);
    } else if (type == Places.TYPE_WIFI) {
      drawable = mCxt.getResources().getDrawable(R.drawable.icon_wifi);
      mIcon.setVisibility(VISIBLE);
      mIcon.setImageDrawable(drawable);
    } else {
      mIcon.setVisibility(GONE);
    }
  }
Ejemplo n.º 19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    try {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.tasks);
      this.tasksList = new ArrayList<Task>();
      ListView lvTasks = (ListView) this.findViewById(R.id.listViewTasks);
      this.tasksListAdapter =
          new ArrayAdapter<Task>(
              this.getApplicationContext(),
              android.R.layout.simple_selectable_list_item,
              this.tasksList);
      lvTasks.setLongClickable(true);
      lvTasks.setAdapter(this.tasksListAdapter);
      this.registerForContextMenu(lvTasks);
      lvTasks.setClickable(true);
      this.sN = (String) this.getIntent().getExtras().getString("subjectName");
      TextView tv = (TextView) this.findViewById(R.id.taskSubjectNameHeader);
      tv.setText(this.sN);
      lvTasks.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              Task actual;
              actual = tasks.this.tasksList.get(position);
              Intent intent = new Intent(tasks.this, viewTask.class);
              intent.putExtra("subjectName", actual.getTaskSubject());
              intent.putExtra("taskDescription", actual.getTaskDescription());
              intent.putExtra("taskDeadline", actual.getTaskDeadline());
              intent.putExtra("taskName", actual.getTaskName());
              startActivity(intent);
            }
          });
    } catch (NullPointerException p) {

      Toast.makeText(
              getApplicationContext(),
              "Please, initialize before creating objects",
              Toast.LENGTH_LONG)
          .show();
    }
  }
  public void setMeatToppingsView() {

    ListView list = (ListView) findViewById(R.id.meatToppingsView);
    String[] meat = {"Pepperoni", "Chicken", "Ground Beef", "Anchovies", "Bacon Bits"};
    List<String> meatList = Arrays.asList(meat);
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, meatList);
    list.setAdapter(adapter);
    list.setClickable(true);
    list.setChoiceMode(list.CHOICE_MODE_MULTIPLE);
    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckedTextView item = (CheckedTextView) view;
            if (item.isChecked()) {
              numMeatToppings++;
            } else {
              numMeatToppings--;
            }
          }
        });
  }
Ejemplo n.º 21
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.portslist);

    dbadapter = new DBAdapter(this.getApplicationContext());
    dbadapter.open();

    portList = (ListView) findViewById(R.id.ListView01);
    hostInfo = (TextView) findViewById(R.id.TextView01);

    portList.setOnCreateContextMenuListener(this);
    portList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    portList.setClickable(true);

    Bundle extras = getIntent().getExtras();
    // extras should ALWAYS contain hostID and hostName
    hostID = extras.getLong(DBAdapter.KEY_HOST_ID);
    hostName = extras.getString(DBAdapter.KEY_HOST);

    hostInfo.setText(hostInfo.getText() + " " + hostName);
    portList.setAdapter(updateList());
  }
Ejemplo n.º 22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lobby);

    gameToJoin = getIntent().getIntExtra(JOIN_GAME_EXTRA, -1);
    if (gameToJoin != -1) {
      // We started from a notification => make sure basic initializations, normally
      // made in MainActivity are performed here:
      GameSettings.setProfile(Profile.Load(PreferenceManager.getDefaultSharedPreferences(this)));
      DrawableManager.InitializeCache(5);
    }

    dataServer = new HttpConnector(getString(R.string.dataserver_url));

    ListView lobbyList = (ListView) findViewById(R.id.mainList);
    checkBoxView = (CheckBox) findViewById(R.id.spectatorCheckboxView);
    lobbyList.setClickable(true);
    listGames();

    if (GameSettings.getLastPlayTime()
        != -1) { // A game has been played, push new playtime to server
      dataServer.sendRequest(
          ServerCommand.SET_PLAYTIME,
          ImmutableMap.of(
              "id", String.valueOf(GameSettings.getUserId()),
              "token", GameSettings.getPlayerToken(),
              "playtime",
                  String.valueOf(
                      GameSettings.getProfile().getPlaytime() + GameSettings.getLastPlayTime())),
          new HttpConnector.Callback() {
            @Override
            public void handleResult(String data) {}
          });
      GameSettings.resetLastPlaytime();
    }
  }
  public void initializeNoteList() {
    ListModel noteListModel = new ListModel();
    Note note;
    int an = 0;

    for (int i = 0; i < searchResults.size(); i++) {

      note = searchResults.get(i);
      noteListModel = new ListModel();

      try {
        an = dbHelper.getAnnotationsOfNote(searchResults.get(i).getNoteName()).size();
      } catch (Exception e) {
        an = 0;
      }

      noteListModel.setNoteName(note.getNoteName());
      noteListModel.setNumAnnotations(an);
      noteListModel.setDateAndTime(note.getDateModified());
      noteListModelArray.add(noteListModel);

      if (noteListModelArray.size() != 0) {
        adapter = new SearchCustomAdapter(this, noteListModelArray, getResources());
        list.setAdapter(adapter);
      }

      list.setClickable(true);
      list.setOnItemClickListener(
          new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parentView, View childView, int position, long id) {
              Intent intent = new Intent(SearchResultsActivity.this, PlayNote.class);
              startActivity(intent);
            }
          });
    }
  }
Ejemplo n.º 24
0
  public TOCDlg(BaseActivity coolReader, ReaderView readerView, TOCItem toc, int currentPage) {
    super(coolReader, coolReader.getResources().getString(R.string.win_title_toc), false, false);
    setCancelable(true);
    //		this.mCoolReader = coolReader;
    this.mReaderView = readerView;
    this.mTOC = toc;
    this.mCurrentPage = currentPage;
    this.mListView = new BaseListView(getContext(), true);
    mListView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> listview, View view, int position, long id) {
            TOCItem item = mItems.get(position);
            if (item.getChildCount() == 0 || item.getExpanded()) {
              mReaderView.goToPage(item.getPage() + 1);
              dismiss();
            } else {
              expand(item);
            }
          }
        });
    mListView.setOnItemLongClickListener(
        new OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(
              AdapterView<?> listview, View view, int position, long id) {
            TOCItem item = mItems.get(position);
            if (item.getChildCount() == 0) {
              mReaderView.goToPage(item.getPage() + 1);
              dismiss();
            } else {
              if (item.getExpanded()) collapse(item);
              else expand(item);
            }
            return true;
          }
        });
    mListView.setLongClickable(true);
    mListView.setClickable(true);
    mListView.setFocusable(true);
    mListView.setFocusableInTouchMode(true);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    setView(mListView);
    setFlingHandlers(
        mListView,
        new Runnable() {
          @Override
          public void run() {
            // cancel
            TOCDlg.this.dismiss();
          }
        },
        new Runnable() {
          @Override
          public void run() {
            //
            TOCDlg.this.dismiss();
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    state = savedInstanceState;

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.composer_list);

    /*
    SharedPreferences myPrefs = this.getSharedPreferences("username", MODE_WORLD_READABLE);
          autoPlay = myPrefs.getBoolean("autoPlay", true);
     */

    list = (ListView) findViewById(R.id.list);
    list.setClickable(true);
    list.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            SMILMessageProxy sm = inbox.get(arg2);
            System.err.println(sm.getFilename());
            Intent i = new Intent(OutboxList.this, ViewMessageActivity.class);
            i.putExtra("title", sm.getFilename());
            i.putExtra("message", sm.getMessage());
            i.putExtra("sender", sm.getSender());
            i.putExtra("index", arg2);

            System.out.println(sm.getModified());
            i.putExtra("date", new SimpleDateFormat("MM/dd/yyyy").format(sm.getModified()));
            i.putExtra("key", sm.getKey());
            OutboxList.this.startActivity(i);
          }
        });

    /*
          alertAutoPlay = new AlertDialog.Builder(this).create();
    alertAutoPlay.setTitle("Did you know?");
    alertAutoPlay.setMessage("If you turn your phone into landscape mode the message will automatically play. Turn your phone back up to return to the message screen.");
    alertAutoPlay.setButton("Let me try!", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
      			return;
          }
    });
    alertAutoPlay.setButton2("Not for me! (disable feature)", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
      			SharedPreferences.Editor myPrefEdit = ComposerList.this.getSharedPreferences("username", MODE_WORLD_READABLE).edit();
      			myPrefEdit.putBoolean("autoPlay", false);
      			myPrefEdit.commit();
      			ComposerList.autoPlay = false;
      			playMessage(true);
      			return;
          }
    });
    */
    alertAddItem = new AlertDialog.Builder(this);
    alertAddItem.setTitle("Add Item");
    final CharSequence[] addItemOptions = {"Text", "Image"};
    alertAddItem.setItems(
        addItemOptions,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialogInterface, int item) {
            System.out.println("Item num: " + item);
            // Intent i = new Intent(InboxList.this, ViewMessageActivity.class);
            // i.putExtra("newItem", addItemOptions[item]);
            // InboxList.this.startActivity(i);
            // this.startActivityForResult(i, REQ_CODE_PLAYER);
          }
        });

    _actionBar = (ActionBar) findViewById(R.id.actionBar);
    _actionBar.setTitle("Outbox");
    _actionBar.setHomeListener(
        new OnClickListener() {
          public void onClick(View v) {
            OutboxList.this.finish();
          }
        });
    _actionBar.addActionIcon(
        R.drawable.ic_list,
        new OnClickListener() {
          public void onClick(View v) {
            alertAddItem.show();
          }
        });
    _actionBar.addActionIcon(
        R.drawable.ic_movie,
        new OnClickListener() {
          public void onClick(View v) {
            playMessage(true);
            return;
          }
        });
    _actionBar.addActionIcon(
        R.drawable.ic_send,
        new OnClickListener() {
          public void onClick(View v) {
            Intent i = new Intent(OutboxList.this, ComposerSend.class);
            OutboxList.this.startActivity(i);
            return;
          }
        });

    /*
    items = new ScrollItemManager(findViewById(R.id.scrollHolder));

    items.addItem(getApplicationContext());
    items.setTitle("Text Item 1");
    items.setListener(this, 1);
    */

  }
Ejemplo n.º 26
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View myView = inflater.inflate(R.layout.simple3_fragment, container, false);

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

    String[] values =
        new String[] {
          "Android",
          "iPhone",
          "WindowsMobile",
          "Blackberry",
          "WebOS",
          "Ubuntu",
          "Windows7",
          "Max OS X",
          "Linux",
          "OS/2"
        };
    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(myContext, android.R.layout.simple_list_item_1, values);
    list.setAdapter(adapter);
    list.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {
            String item = list.getAdapter().getItem(position).toString();
            Toast.makeText(myContext, item + " selected", Toast.LENGTH_LONG).show();
          }
        });

    up = (Button) myView.findViewById(R.id.up);
    up.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // up button, so move the list up
            int i = list.getSelectedItemPosition();
            // Toast.makeText(simple3.this, "up selected is " + i,Toast.LENGTH_LONG).show();
            if (i == ListView.INVALID_POSITION) { // nothing selected, so select first position.
              list.setSelection(0);
            }
            if (i > 0) {
              list.setSelection(i - 1);
            }
          }
        });

    down = (Button) myView.findViewById(R.id.down);
    down.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // down button, so move the it down
            int i = list.getSelectedItemPosition();
            // Toast.makeText(simple3.this, "down selected is " + i, Toast.LENGTH_LONG).show();
            list.setSelection(list.getCount());
          }
        });

    return myView;
  }
Ejemplo n.º 27
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.clp_fragment_2, container, false);

    opArticol = OperatiiArticolFactory.createObject("OperatiiArticolImpl", getActivity());
    opArticol.setListener(this);

    nf2 = NumberFormat.getInstance();

    this.tglButton = (ToggleButton) v.findViewById(R.id.togglebuttonClp);
    addListenerToggle();
    this.tglButton.setChecked(true);

    operatiiClp = new ClpDAO(getActivity());
    operatiiClp.setClpDAOListener(this);

    this.tglTipArtBtn = (ToggleButton) v.findViewById(R.id.tglTipArtClp);
    addListenerTglTipArtBtn();

    txtNumeArticol = (EditText) v.findViewById(R.id.txtNumeArtClp);

    this.articoleBtn = (Button) v.findViewById(R.id.articoleBtnClp);
    addListenerBtnArticole();

    this.listViewArticole = (ListView) v.findViewById(R.id.listArticole);

    textValoareGreutate = (TextView) v.findViewById(R.id.textValoareGreutate);

    textTotalGreutate = (TextView) v.findViewById(R.id.textTotalGreutate);
    layoutTotalGreutate = (LinearLayout) v.findViewById(R.id.layoutTotalGreutate);
    layoutTotalGreutate.setVisibility(View.INVISIBLE);

    layoutGreutate = (LinearLayout) v.findViewById(R.id.layoutGreutate);
    layoutGreutate.setVisibility(View.INVISIBLE);

    listViewArticole.setOnItemClickListener(new MyOnItemSelectedListener());

    spinnerDepoz = (Spinner) v.findViewById(R.id.spinnerDepozClp);
    ArrayAdapter<String> adapterSpinnerDepoz =
        new ArrayAdapter<String>(
            getActivity(), android.R.layout.simple_spinner_item, getDepozite());
    adapterSpinnerDepoz.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerDepoz.setAdapter(adapterSpinnerDepoz);
    spinnerDepoz.setOnItemSelectedListener(new OnSelectDepozit());

    textNumeArticol = (TextView) v.findViewById(R.id.textNumeArticolClp);
    textNumeArticol.setVisibility(View.INVISIBLE);
    textCodArticol = (TextView) v.findViewById(R.id.textCodArticolClp);
    textCodArticol.setVisibility(View.INVISIBLE);

    labelStoc = (TextView) v.findViewById(R.id.labelStocClp);
    labelStoc.setVisibility(View.INVISIBLE);

    textStoc = (TextView) v.findViewById(R.id.textStocClp);
    textStoc.setVisibility(View.INVISIBLE);

    textUm = (TextView) v.findViewById(R.id.textUmClp);
    textUm.setVisibility(View.INVISIBLE);

    labelCantArt = (TextView) v.findViewById(R.id.labelCantArtClp);
    labelCantArt.setVisibility(View.INVISIBLE);
    textCantArt = (EditText) v.findViewById(R.id.txtCantArtClp);
    textCantArt.setVisibility(View.INVISIBLE);

    layoutArtHeader = (LinearLayout) v.findViewById(R.id.layoutHeaderArtClp);
    layoutArtDet = (LinearLayout) v.findViewById(R.id.layoutDetArtClp);

    this.slidingDrawerArt = (SlidingDrawer) v.findViewById(R.id.articoleSlidingDrawer);
    addDrawerListener();

    listArtCmdClp = (ListView) v.findViewById(R.id.listArtCmdClp);

    listArtSelClp = new ArrayList<HashMap<String, String>>();
    adapterListArtClp =
        new SimpleAdapter(
            getActivity(),
            listArtSelClp,
            R.layout.articol_row_clp,
            new String[] {
              "nrCrt",
              "numeArt",
              "codArt",
              "cantArt",
              "depozit",
              "Umb",
              "sintetic",
              "greutate",
              "umgreutate",
              "depart"
            },
            new int[] {
              R.id.textNrCrt,
              R.id.textNumeArt,
              R.id.textCodArt,
              R.id.textCantArt,
              R.id.textDepozit,
              R.id.textCantUmb,
              R.id.textSintetic,
              R.id.textGreutate,
              R.id.textUmGreutate,
              R.id.textDepart
            });

    listArtCmdClp.setAdapter(adapterListArtClp);
    listArtCmdClp.setClickable(true);
    addListenerListArtSel();
    registerForContextMenu(listArtCmdClp);

    this.saveArtBtnClp = (Button) v.findViewById(R.id.saveArtBtnClp);
    this.saveArtBtnClp.setVisibility(View.INVISIBLE);
    addListenerBtnSaveArticole();

    layoutSaveClp = (TableLayout) v.findViewById(R.id.layoutSaveClp);
    layoutSaveClp.setVisibility(View.INVISIBLE);

    CLPFragment2.slidingDrawerSaveClp = (SlidingDrawer) v.findViewById(R.id.slidingDrawerClp);
    addDrawerClpListener();

    this.slideButtonClp = (Button) v.findViewById(R.id.slideButtonClp);

    this.saveClpButton = (Button) v.findViewById(R.id.saveClpBtn);
    addListenerSaveClpBtn();

    mProgressClp = (ProgressBar) v.findViewById(R.id.progress_bar_saveclp);
    mProgressClp.setVisibility(View.INVISIBLE);

    spinnerUMClp = (Spinner) v.findViewById(R.id.spinnerUMClp);

    listUmVanz = new ArrayList<HashMap<String, String>>();
    adapterUmVanz =
        new SimpleAdapter(
            getActivity(),
            listUmVanz,
            R.layout.simplerowlayout,
            new String[] {"rowText"},
            new int[] {R.id.textRowName});
    spinnerUMClp.setAdapter(adapterUmVanz);
    spinnerUMClp.setVisibility(View.GONE);
    spinnerUMClp.setOnItemSelectedListener(new OnSelectUnitMas());

    comandaCLP = new ComandaCreataCLP();

    return v;
  }
Ejemplo n.º 28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    String pesan;
    if (mBluetoothAdapter == null) {
      pesan = "Tidak ada bluetooth!";
      finish(); // keluar
    } else {
      pesan = "Ada bluetooth!";
    }
    Toast toast = Toast.makeText(getApplicationContext(), pesan, Toast.LENGTH_LONG);
    toast.show();

    // init listview
    ListView lv = (ListView) findViewById(R.id.listView);
    // set warna abu2, karena default font adalah putih
    lv.setBackgroundColor(Color.LTGRAY);
    adapter = new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1, items);
    lv.setAdapter(adapter);
    tampilkanPaired();

    if (!mBluetoothAdapter.isEnabled()) {
      // bluetooth dalam kondisi off
      // menampilkan dialog untuk menyalakan bluetooth (jika sedang mati)
      // setelah user memilih method onActivityResult akan ditrigger
      Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
      startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
    }

    // mulai android 6, device discovery bluetooth perlu ijin lokasi
    if (ContextCompat.checkSelfPermission(
            this,
            // hati2, jika konstanta tidak cocok, tidak ada runtimeerror
            Manifest.permission.ACCESS_COARSE_LOCATION)
        != PackageManager.PERMISSION_GRANTED) {

      ActivityCompat.requestPermissions(
          this, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSIONS_REQUEST);
      // MY_PERMISSIONS_REQUEST adalah konstanta, nanti digunakan di  onRequestPermissionsResult
    } else {
      // sudah diijinkan
      isIjinLokasi = true;
    }

    tvHasil = (TextView) findViewById(R.id.tvHasil);

    // siapkan onclik pada listview
    // artinya client menghubungi server
    lvServer = (ListView) findViewById(R.id.listView);
    lvServer.setClickable(true);
    lvServer.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            BluetoothDevice devicePilih = arrayPairedDevices.get(position);
            client(devicePilih);
          }
        });
  }
Ejemplo n.º 29
0
  @Override
  public void createAndAttachView(final int id, FrameLayout frame) {
    LayoutInflater inflater = LayoutInflater.from(this);

    // choose which type of window to show
    if (APP_SELECTOR_ID == id) {
      final View view = inflater.inflate(R.layout.app_selector, frame, true);
      final ListView listView = (ListView) view.findViewById(R.id.list);
      final List<ActivityInfo> apps = new ArrayList<ActivityInfo>();

      listView.setClickable(true);

      final AppAdapter adapter = new AppAdapter(this, R.layout.app_row, apps);
      listView.setAdapter(adapter);

      listView.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
              Window window = getWindow(id);

              // close self
              close(id);

              ActivityInfo app = (ActivityInfo) parent.getItemAtPosition(position);

              // send data back
              if (window.data.containsKey("fromId")) {
                Bundle data = new Bundle();
                data.putParcelable("app", app);
                sendData(
                    id,
                    FloatingFolder.class,
                    window.data.getInt("fromId"),
                    APP_SELECTOR_FINISHED_CODE,
                    data);
              }
            }
          });

      new Thread(
              new Runnable() {

                @Override
                public void run() {
                  final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
                  mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                  final List<ResolveInfo> resolveApps =
                      getPackageManager().queryIntentActivities(mainIntent, 0);

                  Collections.sort(
                      resolveApps,
                      new Comparator<ResolveInfo>() {

                        @Override
                        public int compare(ResolveInfo app1, ResolveInfo app2) {
                          String label1 = app1.loadLabel(mPackageManager).toString();
                          String label2 = app2.loadLabel(mPackageManager).toString();
                          return label1.compareTo(label2);
                        }
                      });

                  for (ResolveInfo resolveApp : resolveApps) {
                    apps.add(resolveApp.activityInfo);
                  }

                  Log.d("FloatingFolder", "before");
                  view.post(
                      new Runnable() {

                        @Override
                        public void run() {
                          Log.d("FloatingFolder", "after");
                          adapter.notifyDataSetChanged();
                        }
                      });
                }
              })
          .start();

      View cancel = view.findViewById(R.id.cancel);
      cancel.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              // close self
              close(id);
            }
          });
    } else {
      // id is not app selector
      View view = inflater.inflate(R.layout.folder, frame, true);

      FlowLayout flow = (FlowLayout) view.findViewById(R.id.flow);

      if (mFolders == null) {
        loadAllFolders();
      }

      FolderModel folder = mFolders.get(id);
      if (folder != null) {
        for (ActivityInfo app : folder.apps) {
          addAppToFolder(id, app, flow);
        }
      }
    }
  }
Ejemplo n.º 30
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    // set the listener for add button
    ImageButton add = (ImageButton) view.findViewById(R.id.sources_add);
    add.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent i = new Intent(getActivity(), NewSourceActivity.class);
            getActivity().startActivityForResult(i, Constants.requestCodes.CREATE_SOURCE);
          }
        });

    //
    // Set Contextual ACTION BAR CALLBACKS
    //
    final SourcesFragment callback = this;
    ListView lv = getListView();
    lv.setLongClickable(true);
    lv.setClickable(true);
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    // edit - delete
    lv.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            LayerStore sel = adapter.getItem(position);

            if (!selected.contains(sel)) {
              getListView().setItemChecked(position, true);
              selected.add(sel);

            } else {
              getListView().setItemChecked(position, false);
              selected.remove(sel);
            }
            int numSelected = selected.size();
            if (numSelected > 0) {
              if (actionMode != null) {
                updateCAB(numSelected);
              } else {
                actionMode = getSherlockActivity().startActionMode(callback);
                // override the done button to deselect all when the button is pressed
                int doneButtonId =
                    Resources.getSystem()
                        .getIdentifier("action_mode_close_button", "id", "android");
                View doneButton = getActivity().findViewById(doneButtonId);
                doneButton.setOnClickListener(
                    new View.OnClickListener() {

                      @Override
                      public void onClick(View v) {
                        getListView().clearChoices();
                        selected = new ArrayList<LayerStore>();
                        actionMode.finish();
                      }
                    });
              }
            } else {
              if (actionMode != null) {
                actionMode.finish();
              }
            }
            view.setSelected(true);
            return true;
          }
        });
    // browse
    lv.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            LayerStore s = (LayerStore) adapter.getItem(position);
            s.openDetails(getSherlockActivity());
          }
        });

    super.onViewCreated(view, savedInstanceState);
  }