Java Code Examples for android.widget.ListView#setAdapter()

The following examples show how to use android.widget.ListView#setAdapter() . 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: PopupHomeActivity.java    From FlycoDialog_Master with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDisplayMetrics = getResources().getDisplayMetrics();

    ListView lv = new ListView(mContext);
    lv.setCacheColorHint(Color.TRANSPARENT);
    lv.setBackgroundColor(Color.WHITE);
    lv.setFadingEdgeLength(0);
    lv.setAdapter(new SimpleHomeAdapter());

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

    setContentView(lv);
}
 
Example 2
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
private void init() {
    mListView = (ListView) findViewById( R.id.list_view );
    mEditText = (EditText) findViewById( R.id.input );
    mSendButton = (Button) findViewById( R.id.btn_send );

    mAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1 );
    mListView.setAdapter( mAdapter );

    mSendButton.setOnClickListener( new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String text = mEditText.getText().toString();
            if (!TextUtils.isEmpty(text)) {
                mAdapter.add(text);
                mAdapter.notifyDataSetChanged();

                sendMessage(WEAR_MESSAGE_PATH, text);
            }
        }
    });
}
 
Example 3
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 4
Source File: NavigationDrawerFragment.java    From chromium-webview-samples 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);
        }
    });
    mDrawerListView.setAdapter(new ArrayAdapter<String>(
            getActionBar().getThemedContext(),
            android.R.layout.simple_list_item_activated_1,
            android.R.id.text1,
            new String[]{
                    getString(R.string.title_section1),
                    getString(R.string.title_section2),
                    getString(R.string.title_section3),
            }));
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    return mDrawerListView;
}
 
Example 5
Source File: Listado.java    From android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listado);

    ListView lvAmigos = (ListView) findViewById(R.id.lvAmigos);
    adapter =
            new AmigoAdapter(this,MainActivity.listaAmigos);
    lvAmigos.setAdapter(adapter);

    registerForContextMenu(lvAmigos);
}
 
Example 6
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
private void initViews() {
    mListView = (ListView) findViewById( R.id.list );
    mItems = getResources().getStringArray(R.array.items);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mItems );
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(this);
}
 
Example 7
Source File: ClassifyFragment.java    From HomeApplianceMall with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_classify, container, false);
    canAC = true;
    myApplication = (MyApplication)getActivity().getApplication();
    listView = (ListView) v.findViewById(R.id.listView_fclass);
    refreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.refreshLayout_f_class);
    layoutTv = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_tv);
    layoutFridge = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_fridge);
    layoutAir = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_air);
    layoutGeyser = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_geyser);
    layoutWasher = (LinearLayout) v.findViewById(R.id.linearLayout_f_class_washer);
    kindMap = new HashMap<>();
    listList = new ArrayList<>();

    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // 刷新操作
            int kind = myApplication.getCurrentKind();
            if(kind<0){
                kind = -1*kind;
                updateData(kind+"");
            }
        }
    });

    layoutTv.setOnClickListener(this);
    layoutFridge.setOnClickListener(this);
    layoutAir.setOnClickListener(this);
    layoutGeyser.setOnClickListener(this);
    layoutWasher.setOnClickListener(this);
    myAdape = new MyAdapterForListGoods(container.getContext(),listList);
    listView.setAdapter(myAdape);
    return v;
}
 
Example 8
Source File: HttpGetCategoriesAction.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings({ "rawtypes" })
@Override
public void onPostExecute(String xml) {
	if (this.exception != null) {
		return;
	}
	if (this.config.type.equals("Bot")) {
		MainActivity.categories = this.categories;
	} else if (this.config.type.equals("Forum")) {
		MainActivity.forumCategories = this.categories;
	} else if (this.config.type.equals("Channel")) {
		MainActivity.channelCategories = this.categories;
	} else if (this.config.type.equals("Avatar")) {
		MainActivity.avatarCategories = this.categories;
	} else if (this.config.type.equals("Script")) {
		MainActivity.scriptCategories = this.categories;
	}else if(this.config.type.equals("Domain")) {
		MainActivity.domainCategories = this.categories;
	}
	
	//extracting everything from this.categories name,icon,description
	listCategories = new ArrayList<ContentConfig>();
	for (int i = 0; i < categories.length; i++) {
		listCategories.add((ContentConfig)this.categories[i]);
	}
	
	//extracting the names from this.categories
	Object[] names = new Object[this.categories.length];
	for (int index = 0; index < this.categories.length; index++) {
		names[index] = (((ContentConfig)this.categories[index]).name);
	}
	
	llview = (ListView) this.activity.findViewById(R.id.theListView);
       if (llview != null) {
        ArrayAdapter adapter = new CategoryListAdapter(this.activity,
                R.layout.image_list, listCategories);
        llview.setAdapter(adapter);
       }
}
 
Example 9
Source File: FaceppActionActivity.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
private void init() {
    mDialogUtil = new DialogUtil(this);
    TextView title = (TextView) findViewById(R.id.title_layout_titleText);
    title.setText(getResources().getString(R.string.title));
    findViewById(R.id.title_layout_returnRel).setVisibility(View.GONE);
    Button enterBtn = (Button) findViewById(R.id.landmark_enterBtn);
    enterBtn.setText(getResources().getString(R.string.detect_face));
    enterBtn.setOnClickListener(this);
    mInflater = LayoutInflater.from(this);
    findViewById(R.id.activity_rootRel).setOnClickListener(this);
    mListRel = (RelativeLayout) findViewById(R.id.landmark_listRel);
    mListRel.setOnClickListener(this);
    mListView = (ListView) findViewById(R.id.landmark_list);
    mListView.setVerticalScrollBarEnabled(false);

    mListAdapter = new ListAdapter();
    mListView.setAdapter(mListAdapter);
    RelativeLayout rel0 = (RelativeLayout) findViewById(R.id.landmark_imageitem_0);
    RelativeLayout rel1 = (RelativeLayout) findViewById(R.id.landmark_imageitem_1);
    RelativeLayout rel2 = (RelativeLayout) findViewById(R.id.landmark_imageitem_2);
    RelativeLayout rel3 = (RelativeLayout) findViewById(R.id.landmark_imageitem_3);
    RelativeLayout rel4 = (RelativeLayout) findViewById(R.id.landmark_imageitem_4);
    RelativeLayout rel5 = (RelativeLayout) findViewById(R.id.landmark_imageitem_5);
    RelativeLayout rel6 = (RelativeLayout) findViewById(R.id.landmark_imageitem_6);
    RelativeLayout rel7 = (RelativeLayout) findViewById(R.id.landmark_imageitem_7);
    imageItem_Rels = new RelativeLayout[]{rel0, rel1, rel2, rel3, rel4, rel5, rel6, rel7};
    RelativeLayout textRel0 = (RelativeLayout) findViewById(R.id.landmark_edititem_0);
    RelativeLayout textRel1 = (RelativeLayout) findViewById(R.id.landmark_edititem_1);
    RelativeLayout textRel2 = (RelativeLayout) findViewById(R.id.landmark_edititem_2);
    RelativeLayout textRel3 = (RelativeLayout) findViewById(R.id.landmark_edititem_3);
    RelativeLayout textRel4 = (RelativeLayout) findViewById(R.id.landmark_edititem_4);
    textItem_Rels = new RelativeLayout[]{textRel0, textRel1, textRel2, textRel3, textRel4};
}
 
Example 10
Source File: EditTemplateActivity.java    From SmileEssence with MIT License 5 votes vote down vote up
private void initializeViews() {
    ListView listView = getListView();
    adapter = new CustomListAdapter<>(this, Template.class);
    listView.setAdapter(adapter);
    adapter.addToTop(getTemplates());
    adapter.update();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setOnItemClickListener(this);
    listView.setMultiChoiceModeListener(this);
}
 
Example 11
Source File: LowpanScanActivity.java    From sample-lowpan with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lowpan_scan);

    mScanButton = findViewById(R.id.scanButton);
    mScanButton.setOnClickListener((view) -> beginScan());

    Button provisionButton = findViewById(R.id.provisionButton);
    provisionButton.setOnClickListener(view -> createNewNetwork());

    Button leaveButton = findViewById(R.id.leaveButton);
    leaveButton.setOnClickListener(view -> leaveNetwork());

    ListView beaconsView = findViewById(R.id.beacons);
    beaconsView.setOnItemClickListener(this);
    mBeaconsAdapter = new LowpanBeaconAdapter(this);
    beaconsView.setAdapter(mBeaconsAdapter);

    mInterfaceStatus = findViewById(R.id.interfaceStatus);
    mNetworkStatus = findViewById(R.id.networkStatus);

    try {
        mLowpanManager.registerCallback(mInterfaceCallback);
    } catch (LowpanException e) {
        Log.e(TAG, "Unable to attach LoWPAN callback");
    }
}
 
Example 12
Source File: SnackbarShowInDialogSampleActivity.java    From snackbar with MIT License 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    View view = LayoutInflater.from(context).inflate(R.layout.fragment_dialog_list, null, false);

    mListView = (ListView) view.findViewById(android.R.id.list);
    mSnackbarContainer = (ViewGroup) view.findViewById(R.id.snackbar_container);

    List<String> data = new ArrayList<String>();

    for (int i = 0; i < 25; i++) {
        data.add(String.format("Item %d", (i + 1)));
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(
            context, android.R.layout.simple_list_item_1, data);

    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(this);

    builder.setView(view);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    return builder.create();
}
 
Example 13
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    lv = (ListView) findViewById(R.id.lv);
    initData();
    adapter = new MyAdapter(list,this);
    lv.setAdapter(adapter);
}
 
Example 14
Source File: DialogUtil.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 多选对话框
 *
 * @param con        上下文
 * @param title      标题
 * @param cancelable 是否可取消
 * @param meumList   选项,key值必须包涵text,isChecked
 * @param listener   点击确认按钮
 */
public static void showMultiMenuDialog(Context con, String title, boolean cancelable, List<HashMap<String, Object>> meumList, DialogInterface.OnClickListener listener) {
    //创建自定义布局
    LinearLayout ll = new LinearLayout(con);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    ll.setLayoutParams(layoutParams);
    ll.setOrientation(LinearLayout.VERTICAL);
    //添加一条线
    LinearLayout line = new LinearLayout(con);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
    line.setBackgroundColor(con.getResources().getColor(R.color.line));
    line.setLayoutParams(lp);
    ll.addView(line);
    //添加列表布局
    ListView lv = new ListView(con);
    lv.setLayoutParams(layoutParams);
    final DialogSelectAdapter adapter = new DialogSelectAdapter(con, meumList, true);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            adapter.onItemClick(view, position);
        }
    });
    ll.addView(lv);
    //创建对话框
    QuickDialog.Builder builder = new QuickDialog.Builder(con);
    builder.setContentView(ll);
    builder.setTitle(title);
    builder.setGravity(Gravity.LEFT);
    builder.setCancelable(cancelable);
    builder.setPositiveButton("确定", listener);
    builder.setNegativeButton("取消", null);
    builder.create().show();
}
 
Example 15
Source File: Main.java    From Android-Music-Player with MIT License 4 votes vote down vote up
public Main(Context context, int width, int height) {
    super(context, width, height);
    setBackgroundColor(0x00000000);
    This = this;

    squre sqTitle = new squre(width, Ui.cd.getHt(50),0,0);
    sqTitle.setColor(titleBack.Color0);
    addShape(sqTitle);

    squre btmSq = new squre(width, Ui.cd.getHt(120),0,height  - Ui.cd.getHt(120 + 60));
    btmSq.setColor(btmBack.Color0);
    addShape(btmSq);

    squre sq = new squre(width,height - Ui.cd.getHt(50) - btmSq.height + - Ui.cd.getHt(60),0, Ui.cd.getHt(50));
    sq.setColor(backgroundImg.Color0);
    addShape(sq);

    squre bmLine = new squre(width, Ui.cd.getHt(2) ,0,btmSq.y+ btmSq.height);
    bmLine.setColor(backgroundImg.Color0);
    addShape(bmLine);

    squre volumeBack = new squre(width, Ui.cd.getHt(60-2) ,0,bmLine.y+ bmLine.height);
    volumeBack.setColor(btmBack.Color0);
    addShape(volumeBack);

    VolumeRocker Vr = new VolumeRocker(getContext(),width,(int)volumeBack.height);
    Vr.setBackgroundResource(0);
    Vr.setY(volumeBack.y);

    addView(Vr);

    FMText title = textImg.getFMText(context,"Equalizer Presets", Ui.cd.getHt(18));
    title.img.setColor(textColor.Color0);
    title.InCenter(width, Ui.cd.getHt(50));
    title.setX(Ui.cd.getHt(10));
    addView(title);

    addWhells((int) btmSq.y, (int) btmSq.height);

    presetAdapter data;
    listview = new ListView(getContext());
    listview.setLayoutParams(new FrameLayout.LayoutParams((int)sq.width,(int)sq.height));
    listview.setY(sq.y);
    listview.setDivider(null);
    listview.setBackgroundResource(0);
    //listview.setBackgroundColor(com.shape.home.slider.backgroundImg.Color0);
    data = new presetAdapter(){
        @Override
        public void onReload(){
            if(listview != null){
                refreshData();
            }
        }
    };
    listview.setAdapter(data);
    addView(listview);

    final radioBtn rBtn = new radioBtn(getContext(), Ui.cd.getHt(95), Ui.cd.getHt(40));
    rBtn.InCenter(width, Ui.cd.getHt(50));
    rBtn.setX(width - rBtn.width - Ui.cd.getHt(5));
    addView(rBtn);


    Ui.ef.playerEvent.addEvent(new EventCall(new int[]{playerEvents.EQ_CHANGED, Ui.ef.Event_onBind}){
        @Override
        public void onCall(int eventId) {
            refreshData();
            rBtn.switchBtn(Ui.ef.MusicPlayer.handler.EQs.isOn);
        }
    });

}
 
Example 16
Source File: DrawService.java    From Float-Bar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 更新悬浮窗布局等
 */
private void updateUi() {
	RIGHT_MODE = !prefs.getDrawMode();
	DRAW_COLOR = prefs.getDrawColor();
	ALPHA = prefs.getDrawAlpha();

	// 获取浮动窗口视图所在布局
	layout = (LinearLayout) inflater.inflate(RIGHT_MODE ? R.layout.draw_right : R.layout.draw_left, null);
	// 添加悬浮窗的视图
	mWindowManager.addView(layout, wmParams);

	/**
	 * 设置抽屉控件的打开方向和监听器
	 */
	mDrawerLayout = (DrawerLayout) layout.findViewById(R.id.drawer_layout);
	mDrawerLayout.setDrawerListener(new MyDrawListener());
	mDrawerLayout.openDrawer(RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT);

	/**
	 * 设置上方的home键
	 */
	Button home = (Button) layout.findViewById(R.id.home_key);
	home.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			Util.virtualHome(getBaseContext());
			stopSelf();
		}
	});

	/**
	 * 设置抽屉控件内的背景
	 */
	drawContent = (LinearLayout) layout.findViewById(R.id.drawer_content);
	drawContent.setBackgroundColor(DRAW_COLOR);
	drawContent.getBackground().setAlpha(ALPHA);

	/**
	 * 设置最近任务list中item的个数:20
	 */
	Util.reloadButtons(this, appInfos, 20);
	ListView listView = (ListView) layout.findViewById(R.id.drawer_list);
	listView.setAdapter(new AppAdapter(this, mWindowManager, layout, mDrawerLayout, appInfos));

	// 悬浮窗显示确定右上角为起始坐标
	wmParams.gravity = RIGHT_MODE ? Gravity.RIGHT : Gravity.LEFT | Gravity.TOP;
	// 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置
	// 添加动画。参考自:http://bbs.9ria.com/thread-242912-1-1.html
	wmParams.windowAnimations = (RIGHT_MODE) ? R.style.right_anim : R.style.left_anim;

	mWindowManager.updateViewLayout(layout, wmParams);
}
 
Example 17
Source File: AccountSelectorWindow.java    From YiBo with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
	LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View contentView = inflater.inflate(R.layout.widget_pop_account_selector, null);
    lvAccountSelector = (ListView)contentView.findViewById(R.id.lvAccountSelector);
    ImageView ivAccountSelectorFooter = (ImageView)contentView.findViewById(R.id.ivAccountSelectorFooter);
    Theme theme = ThemeUtil.createTheme(context);
    ThemeUtil.setContentBackground(lvAccountSelector);
    ThemeUtil.setListViewStyle(lvAccountSelector);
    ivAccountSelectorFooter.setBackgroundDrawable(theme.getDrawable("selector_bg_footer_account_selector"));
    
    View footerView = null;
    if (mode == SelectMode.Single) {
    	footerView = inflater.inflate(R.layout.list_item_account_manage, null);
    	LinearLayout llAccountManage = (LinearLayout)footerView.findViewById(R.id.llAccountManage);
    	ImageView ivProfileImage = (ImageView)footerView.findViewById(R.id.ivProfileImage);
    	TextView tvProfileName = (TextView)footerView.findViewById(R.id.tvProfileName);
    	TextView tvImpress = (TextView)footerView.findViewById(R.id.tvImpress);
    	ImageView ivMoreDetail = (ImageView)footerView.findViewById(R.id.ivMoreDetail);
    	llAccountManage.setBackgroundDrawable(theme.getDrawable("selector_frame_item_no_corner"));
    	llAccountManage.setPadding(theme.dip2px(8), theme.dip2px(4), 
    		theme.dip2px(16), theme.dip2px(4));
    	ivProfileImage.setImageDrawable(theme.getDrawable("icon_group"));
    	tvProfileName.setTextColor(theme.getColor("content"));
    	tvImpress.setTextColor(theme.getColor("remark"));
    	ivMoreDetail.setBackgroundDrawable(theme.getDrawable("icon_more_detail"));
    	
    	footerView.setOnClickListener(new AccountManageClickListener(this));
    } else {
    	footerView = inflater.inflate(R.layout.list_item_account_selector_operate, null);
    	Button btnSelectAll = (Button)footerView.findViewById(R.id.btnSelectAll);
    	Button btnSelectInverse = (Button)footerView.findViewById(R.id.btnSelectInverse);
    	ThemeUtil.setBtnActionPositive(btnSelectAll);
    	ThemeUtil.setBtnActionNegative(btnSelectInverse);
    	
    	AccountSelectorOperateClickListener operateClickListener =
    		new AccountSelectorOperateClickListener(this);
    	btnSelectAll.setOnClickListener(operateClickListener);
    	btnSelectInverse.setOnClickListener(operateClickListener);
    }
    lvAccountSelector.addFooterView(footerView);

    listAdapter = new AccountSelectorListAdapter(context, mode, isShowSnsAccount);
    lvAccountSelector.setAdapter(listAdapter);

    popList = new PopupWindow(contentView, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    popList.setBackgroundDrawable(new BitmapDrawable());
    popList.setFocusable(true);
    popList.setOutsideTouchable(true);
}
 
Example 18
Source File: MainPageActivity.java    From AndroidFaceRecognizer with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_page);
	
	
	adView = new AdView(this);
	adView.setAdUnitId("ca-app-pub-4147454460675251/3837655321");
	adView.setAdSize(AdSize.BANNER);
	
	adView.setAdListener(adListener);
	
	RelativeLayout adLayout = (RelativeLayout)findViewById(R.id.main_page_adview_layout);
	adLayout.addView(adView);
	
	RelativeLayout.LayoutParams adViewlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	adViewlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	adViewlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
	adView.setLayoutParams(adViewlp);

	
	AdRequest request = new AdRequest.Builder()
	.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("04E14595EE84A505616E50A99B15252D")
    .build();
	
	
	adView.loadAd(request);
	
	System.out.println("---------------------- istestdevice: "+request.isTestDevice(this));

	
	mContext = this;
	
	DisplayMetrics dm = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( dm );
	
	screenWidth = dm.widthPixels;
	screenHeight = dm.heightPixels;
	
	final TextView headerText = (TextView)findViewById(R.id.mainHeaderText);
	RelativeLayout.LayoutParams headerTextParams = (RelativeLayout.LayoutParams)headerText.getLayoutParams();
	headerTextParams.leftMargin = screenHeight/8;
	headerText.setLayoutParams(headerTextParams);
	headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float)screenHeight/35);
	headerText.setText("Face Recognition");
	headerText.setTextColor(Color.LTGRAY);
	headerText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	headerText.setTypeface(null, Typeface.BOLD);
	
	ImageView headerIcon = (ImageView)findViewById(R.id.mainHeaderIcon);
	RelativeLayout.LayoutParams iconLParams = new RelativeLayout.LayoutParams(screenHeight/11, screenHeight/11);
	iconLParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT | RelativeLayout.CENTER_VERTICAL);
	iconLParams.leftMargin = screenHeight/80;
	headerIcon.setLayoutParams(iconLParams);
	
	
	ListView listView = (ListView)findViewById(R.id.mainListView);
	ListAdapter listAdapter = new ListAdapter();
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(itemClickListener);
	
	RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)listView.getLayoutParams();
	params.leftMargin = screenWidth/10;
	params.rightMargin = screenWidth/10;
	params.topMargin = screenHeight/12;
	listView.setLayoutParams(params);
	listView.setVerticalScrollBarEnabled(false);

}
 
Example 19
Source File: PreferenceScreen.java    From PreferenceFragment with Apache License 2.0 3 votes vote down vote up
/**
 * Binds a {@link ListView} to the preferences contained in this {@link PreferenceScreen} via
 * {@link #getRootAdapter()}. It also handles passing list item clicks to the corresponding
 * {@link Preference} contained by this {@link PreferenceScreen}.
 * 
 * @param listView
 *            The list view to attach to.
 */
public void bind(ListView listView) {
    listView.setOnItemClickListener(this);
    listView.setAdapter(getRootAdapter());

    onAttachedToActivity();
}
 
Example 20
Source File: EnrollCourses.java    From android-apps with MIT License 2 votes vote down vote up
private void loadListView(ArrayList<EnrollCourse> enrollList) {
	
	ListView listView = (ListView) findViewById(R.id.enrollListAll);
			
	listView.setAdapter(new EnrollAdapter(this, enrollList));
}