android.widget.ListView Java Examples

The following examples show how to use android.widget.ListView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HeaderActivity.java    From PullRefreshView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_header);

    flingLayout = (FlingLayout) findViewById(R.id.root);
    listView = (ListView) findViewById(R.id.list);
    footerView = (BaseFooterView) findViewById(R.id.footer);
    animHeader = findViewById(R.id.anim_header);
    scrollGeter = ViewScrollUtil.getScrollGeter(listView);

    list = getData(15);

    adapter = new ArrayAdapter(this, R.layout.item, list);

    listView.setAdapter(adapter);
    flingLayout.setOnScrollListener(this);
    listView.setOnScrollListener(this);
    footerView.setOnLoadListener(this);
}
 
Example #2
Source File: NavigationDrawerFragment.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    mDrawerListView = (ListView) inflater.inflate(
            R.layout.recyclerview_playground_fragment_navigation_drawer, container, false);
    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }
    });
    mDrawerListView.setAdapter(new ArrayAdapter<String>(
            getActivity(),
            android.R.layout.simple_list_item_activated_1,
            android.R.id.text1,
            new String[]{
                    "title_section1",
                    "title_section2",
                    "title_section3",
                    "title_section4",
            }));
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    return mDrawerListView;
}
 
Example #3
Source File: ResultActivityTest.java    From aedict with GNU General Public License v3.0 6 votes vote down vote up
public void testEdictExternSearch() throws Exception {
	final Intent i = new Intent(getInstrumentation().getContext(), ResultActivity.class);
	i.setAction(ResultActivity.EDICT_ACTION_INTERCEPT);
	i.putExtra(ResultActivity.EDICT_INTENTKEY_KANJIS, "空白");
	tester.startActivity(i);
	assertTrue(tester.getText(R.id.textSelectedDictionary).contains("Default"));
	final ListView lv = getActivity().getListView();
	assertEquals(1, lv.getCount());
	DictEntry entry = (DictEntry) lv.getItemAtPosition(0);
	assertEquals("Searching", entry.english);
	Thread.sleep(500);
	final Intent i2 = getStartedActivityIntent();
	final List<DictEntry> result = (List<DictEntry>) i2.getSerializableExtra(ResultActivity.INTENTKEY_RESULT_LIST);
	entry = result.get(0);
	assertEquals("(adj-na,n,adj-no) blank space/vacuum/space/null (NUL)/(P)", entry.english);
	assertEquals("空白", entry.getJapanese());
	assertEquals("くうはく", entry.reading);
	assertEquals(1, result.size());
}
 
Example #4
Source File: SavedFragment.java    From minx with MIT License 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    enterPinTxt = (FontText) getView().findViewById(R.id.enter_pin_txt);
    userArchivePinTxt = (EditText) getView().findViewById(R.id.userArchivePinTxt);
    btnRetrieveArchive = (Button) getView().findViewById(R.id.btnRetrieveArchive);
    listViewSaved = (ListView) getView().findViewById(R.id.saved_list);

    if(checkPINEnabled()){
        enterPinTxt.setVisibility(View.GONE);
        userArchivePinTxt.setVisibility(View.GONE);
        btnRetrieveArchive.setVisibility(View.GONE);
        loadSavedData();
    }else{
        settingsPreferences = new SettingsPreferences(getActivity());
        if(!settingsPreferences.retrievePINTemp()){
            loadPIN();
        }else{
            enterPinTxt.setVisibility(View.GONE);
            userArchivePinTxt.setVisibility(View.GONE);
            btnRetrieveArchive.setVisibility(View.GONE);
            loadSavedData();
        }
    }
}
 
Example #5
Source File: ListViewUtil.java    From MVPAndroidBootstrap with Apache License 2.0 6 votes vote down vote up
/**** Method for Setting the Height of the ListView dynamically.
 **** Hack to fix the issue of not showing all the items of the ListView
 **** when placed inside a ScrollView  ****/
public static void setListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter mAdapter = listView.getAdapter();

    int totalHeight = 0;

    for (int i = 0; i < mAdapter.getCount(); i++) {
        View mView = mAdapter.getView(i, null, listView);

        mView.measure(
                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),

                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));

        totalHeight += mView.getMeasuredHeight();
        Log.w("HEIGHT" + i, String.valueOf(totalHeight));

    }

    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight
            + (listView.getDividerHeight() * (mAdapter.getCount() - 1));
    listView.setLayoutParams(params);
    listView.requestLayout();
}
 
Example #6
Source File: NavigationDrawerFragment.java    From abelana with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    mDrawerListView = (ListView) inflater.inflate(
            R.layout.fragment_navigation_drawer, container, false);
    mDrawerListView
            .setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                                        int position, long id) {
                    selectItem(position);
                }
            });

    DrawerListAdapter adapter = new DrawerListAdapter(getActivity()
            .getApplicationContext(), mNavItems);
    mDrawerListView.setAdapter(adapter);
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    mDrawerListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    return mDrawerListView;
}
 
Example #7
Source File: SimpleHomeActivity.java    From FlycoPageIndicator with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = new ListView(context);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter(context, items));

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(context, classes[position]);
            startActivity(intent);
        }
    });

    setContentView(lv);
}
 
Example #8
Source File: VideoSelectorActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
public void bindViews() {
    lv_videos = (ListView) this.findViewById(R.id.lv_videos);
    QtNewActionBar actionBar = (QtNewActionBar) this.findViewById(R.id.my_action_bar);
    setNewActionBar(actionBar);
    setActionBarTitle(R.string.atom_ui_title_select_video);
    setActionBarRightIcon(R.string.atom_ui_new_send);
    setActionBarRightIconClick(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mSelectedNumber == -1) {
                Toast.makeText(VideoSelectorActivity.this, getString(R.string.atom_ui_tip_select_video), Toast.LENGTH_SHORT).show();
            } else {
                Intent resultIntent = new Intent();
                resultIntent.putExtra("filepath", videos.get(mSelectedNumber).path);
                setResult(Activity.RESULT_OK, resultIntent);
                finish();
            }
        }
    });

}
 
Example #9
Source File: ChooseTagActivity.java    From sprinkles with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.acitivty_choose_tag);

	mNoteId = getIntent().getLongExtra(EXTRA_NOTE_ID, -1);

	Query.many(Tag.class, "select * from Tags").getAsync(
			getLoaderManager(), onTagsLoaded);
	Query.many(NoteTagLink.class,
			"select * from NoteTagLinks where note_id=?", mNoteId).getAsync(
			getLoaderManager(), onLinksLoaded, Note.class, Tag.class);

	mListView = (ListView) findViewById(R.id.list);
	mListView.setEmptyView(findViewById(R.id.empty));
	mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
	mListView.setOnItemClickListener(onListItemClicked);

	mAdapter = new TagsAdapter(this);
	mListView.setAdapter(mAdapter);
}
 
Example #10
Source File: DonationsDialog.java    From Orin with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostExecute(List<SkuDetails> skuDetails) {
    super.onPostExecute(skuDetails);
    DonationsDialog dialog = donationDialogWeakReference.get();
    if (dialog == null) return;

    if (skuDetails == null || skuDetails.isEmpty()) {
        dialog.dismiss();
        return;
    }

    View customView = ((MaterialDialog) dialog.getDialog()).getCustomView();
    //noinspection ConstantConditions
    customView.findViewById(R.id.progress_container).setVisibility(View.GONE);
    ListView listView = ButterKnife.findById(customView, R.id.list);
    listView.setAdapter(new SkuDetailsAdapter(dialog, skuDetails));
    listView.setVisibility(View.VISIBLE);
}
 
Example #11
Source File: TreeListViewAdapter.java    From AndroidTreeView with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 创建一个新的实例 TreeListViewAdapter. 
 * @param context			上下文
 * @param mTree				展示用的ListView
 * @param datas				数据集
 * @param defaultLevel		默认展开层级
 * @throws IllegalArgumentException 
 * @throws IllegalAccessException 
 */
public TreeListViewAdapter(Context context,ListView tree, List<T> datas, int defaultExpandLevel) throws IllegalAccessException, IllegalArgumentException {
	mContext = context;
	mInflater = LayoutInflater.from(context);
	mAllNodes = TreeHelper.getSortedNodes(datas, defaultExpandLevel);
	mVisibleNodes = TreeHelper.fliterVisibleNodes(mAllNodes);
	for (Node node : mVisibleNodes) {
		Log.e("TAG", "显示--"+node.getName());
	}
	mTree = tree;
	
	mTree.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			expandOrCollapse(position);
			
			if (mListener != null) {
				mListener.onClick(mVisibleNodes.get(position), position);
			}
		}
	});
}
 
Example #12
Source File: LauncherActivity.java    From CountDownTask with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView listView = new ListView(this);
    setContentView(listView);

    Log.d(TAG, TAG + " task id: " + getTaskId());

    Intent intent = getIntent();
    String path = intent.getStringExtra(getPackageName() + ".Path");

    if (path == null) {
        path = "";
    }

    listView.setAdapter(new SimpleAdapter(this, getData(path),
            android.R.layout.simple_list_item_1, new String[]{"title"},
            new int[]{android.R.id.text1}));
    listView.setTextFilterEnabled(true);
    listView.setOnItemClickListener(this);
}
 
Example #13
Source File: ListFragment.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    String item = (String) l.getAdapter().getItem(position);

    if (item.equals(HANDLER)) {
        getFragmentManager().beginTransaction()
                .replace(R.id.root_container, HandlerFragment.newInstance())
                .addToBackStack(null)
                .commit();
    } else if (item.equals(WEB_VIEW)) {
        getFragmentManager().beginTransaction()
                .replace(R.id.root_container, WebViewFragment.newInstance())
                .addToBackStack(null)
                .commit();
    }

    ((ActionBarActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example #14
Source File: MainActivity.java    From Android-Example with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
  
 metrics = new DisplayMetrics();
 getWindowManager().getDefaultDisplay().getMetrics(metrics);

 listview = new ListView(this);
 listview.setFadingEdgeLength(0);
 ArrayList<String> strings = new ArrayList<String>();

 for (int i = 0; i < 300; i++) {
  strings.add("Item:#" + (i + 1));
 }

 MainAdapter mAdapter = new MainAdapter(this, strings, metrics);
 listview.setAdapter(mAdapter);
 setContentView(listview);
}
 
Example #15
Source File: PlacePickerFragment.java    From facebook-api-android-maven with Apache License 2.0 6 votes vote down vote up
@Override
void setupViews(ViewGroup view) {
    if (showSearchBox) {
        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);

        View searchHeaderView = getActivity().getLayoutInflater().inflate(
                R.layout.com_facebook_picker_search_box, listView, false);

        listView.addHeaderView(searchHeaderView, null, false);

        searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text);

        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
            searchBox.setText(searchText);
        }
    }
}
 
Example #16
Source File: BgColorPickDialogFragment.java    From jianshi with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  View root = inflater.inflate(R.layout.fragment_bg_color_pick, container, false);
  getDialog().setTitle(getResources().getString(R.string.please_choose_bg_color));
  colorListView = (ListView) root.findViewById(R.id.bg_color_list_view);
  colorListView.setAdapter(new BgColorPickAdapter(getActivity()));

  return root;
}
 
Example #17
Source File: SecurityHistory.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    listView = (ListView) view.findViewById(R.id.security_history_list);
    listView.setAdapter(new HistoryFragmentListAdapter(getActivity(), new ArrayList<HistoryLog>()));
    return view;
}
 
Example #18
Source File: MineFragment.java    From letv with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    int i;
    this.mMineListView = (ListView) this.mMineRootLayout.findViewById(R.id.my_list_view);
    this.mHeadLayout = PublicLoadLayout.inflate(getActivity(), R.layout.mine_head_layout, null);
    this.mRoundHead = (RoundImageView) this.mHeadLayout.findViewById(R.id.btn_head_login);
    this.mTitle = (TextView) this.mHeadLayout.findViewById(R.id.head_login_title);
    this.mSubTitle = (TextView) this.mHeadLayout.findViewById(R.id.head_login_subtitle);
    this.mSubTitleOther = (TextView) this.mHeadLayout.findViewById(R.id.head_login_subtitle_other);
    this.mHeadLoginLayout = this.mHeadLayout.findViewById(R.id.layout_head_login);
    this.mMessageIcon = (RelativeLayout) this.mHeadLayout.findViewById(R.id.message_icon);
    this.mNewMessageIcon = (ImageView) this.mHeadLayout.findViewById(R.id.new_message_title);
    ImageView imageView = this.mNewMessageIcon;
    if (this.mIsNewMessageVisible) {
        i = 0;
    } else {
        i = 8;
    }
    imageView.setVisibility(i);
    this.mHeadLayout.findViewById(R.id.title_main_search).setVisibility(8);
    this.mMineListView.addHeaderView(this.mHeadLayout);
    View mFooterView = new View(getActivity());
    mFooterView.setLayoutParams(new LayoutParams(-1, UIsUtils.zoomWidth(15)));
    mFooterView.setBackgroundColor(getActivity().getResources().getColor(2131493362));
    this.mMineListView.addFooterView(mFooterView);
    this.mMineListViewAdapter = new MineListViewAdapter(getActivity());
    this.mMineListView.setAdapter(this.mMineListViewAdapter);
    this.mRoundHead.setOnClickListener(this);
    this.mHeadLoginLayout.setOnClickListener(this);
    this.mMessageIcon.setOnClickListener(this);
    showDefaultProfileList();
}
 
Example #19
Source File: ClassesListActivity.java    From android-classyshark with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_classes_list);

    lv = (ListView) findViewById(R.id.listView);
    uriFromIntent = getIntent().getData();
    classesList = new ClassesNamesList();

    setActionBar();

    InputStream uriStream;
    try {

        mProgressDialog = new ProgressDialog(ClassesListActivity.this);
        mProgressDialog.setIcon(R.mipmap.ic_launcher);
        mProgressDialog.setMessage("¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º>");
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mProgressDialog.show();

        uriStream = UriUtils.getStreamFromUri(ClassesListActivity.this,
                uriFromIntent);

        final byte[] bytes = IOUtils.toByteArray(uriStream);

        new FillClassesNamesThread(bytes).start();

        new StartDexLoaderThread(bytes).start();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #20
Source File: SearchGroupMember.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
private void findViewIds(){
	mLayback    = (RelativeLayout)findViewById(R.id.layBack);		
	listview    = (ListView)findViewById(R.id.lvList);		
	relProgress = (RelativeLayout)findViewById(R.id.layProgressresult);		
	layMain     = (LinearLayout)findViewById(R.id.layMain);	
	edtSearch   = (EditText)findViewById(R.id.edtGroupSearch);
	txtType = (TextView)findViewById(R.id.txtTypeSearch);
	txtType.setTypeface(ManagerTypeface.getTypeface(SearchGroupMember.this, R.string.typeface_roboto_regular));
}
 
Example #21
Source File: SwipeRefreshListFragment.java    From catnut with MIT License 5 votes vote down vote up
/**
 * Utility method to check whether a {@link ListView} can scroll up from it's current position.
 * Handles platform version differences, providing backwards compatible functionality where
 * needed.
 */
private static boolean canListViewScrollUp(ListView listView) {
	if (android.os.Build.VERSION.SDK_INT >= 14) {
		// For ICS and above we can call canScrollVertically() to determine this
		return ViewCompat.canScrollVertically(listView, -1);
	} else {
		// Pre-ICS we need to manually check the first visible item and the child view's top
		// value
		return listView.getChildCount() > 0 &&
				(listView.getFirstVisiblePosition() > 0
						|| listView.getChildAt(0).getTop() < listView.getPaddingTop());
	}
}
 
Example #22
Source File: LynxView.java    From Lynx with Apache License 2.0 5 votes vote down vote up
private void mapGui() {
  lv_traces = (ListView) findViewById(R.id.lv_traces);
  lv_traces.setTranscriptMode(AbsListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
  et_filter = (EditText) findViewById(R.id.et_filter);
  ib_share = (ImageButton) findViewById(R.id.ib_share);
  sp_filter = (Spinner) findViewById(R.id.sp_filter);

  configureCursorColor();
  updateFilterText();
}
 
Example #23
Source File: ListActivity.java    From RichLinkPreview with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    listView = (ListView) findViewById(R.id.list);

    ArrayList<URL> urls = new ArrayList<>();

    try {
        urls.add(new URL("https://www.flipkart.com/"));
        urls.add(new URL("https://google.com"));
        urls.add(new URL("https://skype.com"));
        urls.add(new URL("https://twitter.com"));
        urls.add(new URL("https://www.flipkart.com/"));
        urls.add(new URL("https://google.com"));
        urls.add(new URL("https://skype.com"));
        urls.add(new URL("https://twitter.com"));
        urls.add(new URL("https://www.flipkart.com/"));
        urls.add(new URL("https://google.com"));
        urls.add(new URL("https://skype.com"));
        urls.add(new URL("https://twitter.com"));
        urls.add(new URL("https://www.flipkart.com/"));
        urls.add(new URL("https://google.com"));
        urls.add(new URL("https://skype.com"));
        urls.add(new URL("https://twitter.com"));

        URLAdapter urlAdapter = new URLAdapter(this, urls);

        listView.setAdapter(urlAdapter);

    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}
 
Example #24
Source File: ScrollState.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private void applyToListView (final ListView lv) {
	// NOTE if this seems unreliable try wrapping setSelection*() calls in lv.post(...).
	final ListAdapter adapter = lv.getAdapter();

	if (this.itemId >= 0L) {
		for (int i = 0; i < adapter.getCount(); i++) {
			if (adapter.getItemId(i) == this.itemId) {
				lv.setSelectionFromTop(i, this.top);
				return;
			}
		}
	}

	// Also search by time before giving up.
	if (this.itemTime > 0L && adapter instanceof TweetListCursorAdapter) {
		final TweetListCursorAdapter tlca = (TweetListCursorAdapter) adapter;
		for (int i = 0; i < tlca.getCount(); i++) {
			final long itime = tlca.getItemTime(i);
			if (itime > 0L && itime <= this.itemTime) {
				lv.setSelectionFromTop(i, 0);
				return;
			}
		}
		LOG.w("Failed to restore scroll state %s to list of %s items.", this, tlca.getCount());
	}
	else {
		LOG.w("Failed to restore scroll state %s.", this);
	}

	lv.setSelection(lv.getCount() - 1);
}
 
Example #25
Source File: TalkChainDialogFragment.java    From SmileEssence with MIT License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    MainActivity activity = (MainActivity) getActivity();
    final Account account = activity.getAccount();
    final Consumer consumer = activity.getConsumer();
    final Twitter twitter = TwitterApi.getTwitter(consumer, account);

    View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_talk_list, null);
    ListView listView = (ListView) view.findViewById(R.id.listview_dialog_talk_list);
    final StatusListAdapter adapter = new StatusListAdapter(getActivity());
    listView.setAdapter(adapter);
    TwitterUtils.tryGetStatus(twitter, account, getStatusID(), new TwitterUtils.StatusCallback() {
        @Override
        public void success(Status status) {
            adapter.addToTop(new StatusViewModel(status, account));
            adapter.updateForce();
            new GetTalkTask(twitter, account, adapter, status.getInReplyToStatusId()).execute();
        }

        @Override
        public void error() {
            dismiss();
        }
    });

    return new AlertDialog.Builder(activity)
            .setTitle(R.string.dialog_title_talk_chain)
            .setView(view)
            .setCancelable(true)
            .create();
}
 
Example #26
Source File: MainActivity.java    From checkey with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    // Start the CAB using the ActionMode.Callback defined above
    ActionBarActivity activity = (ActionBarActivity) getActivity();
    selectedItem = position;
    AppEntry appEntry = (AppEntry) adapter.getItem(selectedItem);
    showCertificateInfo(activity, appEntry.getPackageName());
}
 
Example #27
Source File: DMConversationAdapter.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public DMConversationAdapter(Fragment fragment, List<DMBean> bean, ListView listView) {
    this.bean = bean;
    this.commander = TimeLineBitmapDownloader.getInstance();
    this.inflater = fragment.getActivity().getLayoutInflater();
    this.fragment = fragment;

}
 
Example #28
Source File: SettingsActivityTest.java    From budget-watch with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAvailableSettings()
{
    ActivityController activityController = Robolectric.buildActivity(SettingsActivity.class).create();
    Activity activity = (Activity)activityController.get();

    activityController.start();
    activityController.resume();
    activityController.visible();

    ListView list = (ListView)activity.findViewById(android.R.id.list);
    shadowOf(list).populateItems();

    List<String> settingTitles = new LinkedList<>
        (Arrays.asList(
            "Receipt Quality"
        ));

    assertEquals(settingTitles.size(), list.getCount());

    for(int index = 0; index < list.getCount(); index++)
    {
        ListPreference preference = (ListPreference)list.getItemAtPosition(0);
        String title = preference.getTitle().toString();

        assertTrue(settingTitles.remove(title));
    }

    assertTrue(settingTitles.isEmpty());
}
 
Example #29
Source File: BotScriptsActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public void upScript() {
	ListView list = (ListView)findViewById(R.id.botScriptList);
	int index = list.getCheckedItemPosition();
	if (index < 0) {
		System.out.println("The other index: " + index);
		MainActivity.showMessage("Select a script to move up in precedence", this);
		return;
	}

	if (index != 0) {
		ScriptConfig script = this.scripts.get(index);
		
		
		ScriptSourceConfig botScript = new ScriptSourceConfig();
		InstanceConfig bot = this.instance;
		botScript.id = script.id;
		botScript.instance = bot.id;
		
		System.out.println("Bot id: " + bot.id + "Bot instance: " + bot.instance 
				+ "ScriptConfig id: " + script.id + "ScriptConfig instance: " + script.instance);
		//This code should change the index of the thing?
		Collections.swap(scripts, index, index-1);

		HttpUpBotScriptAction action = new HttpUpBotScriptAction(this, botScript);
		action.execute();

	}

}
 
Example #30
Source File: RecentActivityActivityTest.java    From Inside_Android_Testing with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    signIn();
    createActivity();

    authenticationGateway = new AuthenticationGateway(apiGateway, activity);
    activityListView = (ListView) activity.findViewById(R.id.recent_activity_list);
}