Search in sources :

Example 1 with SimpleAdapter

use of android.widget.SimpleAdapter in project CurtainView by aicaprio.

the class SampleActivity method showSample2.

private void showSample2() {
    setContentView(R.layout.activity_sample2);
    final CurtainView curtainView = (CurtainView) findViewById(R.id.cv1);
    final ImageView iv1 = (ImageView) findViewById(R.id.iv1);
    final GridView gv1 = (GridView) findViewById(R.id.gv1);
    final List<Map<String, Integer>> data = getData();
    gv1.setAdapter(new SimpleAdapter(this, data, R.layout.item_numbers, new String[] { TEXT_TAG }, new int[] { R.id.item_tvNum }));
    gv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showToast(data.get(position).get(TEXT_TAG) + " clicked");
        }
    });
    iv1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            curtainView.toggleStatus();
        }
    });
    curtainView.setScrollerInterpolator(new BounceInterpolator());
    curtainView.post(new Runnable() {

        @Override
        public void run() {
            curtainView.setCurtainGravityAndFixedValue(null, iv1.getHeight());
        }
    });
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) SimpleAdapter(android.widget.SimpleAdapter) GridView(android.widget.GridView) ImageView(android.widget.ImageView) CurtainView(com.movitech.aicaprio.CurtainView) View(android.view.View) AdapterView(android.widget.AdapterView) CurtainView(com.movitech.aicaprio.CurtainView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) GridView(android.widget.GridView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with SimpleAdapter

use of android.widget.SimpleAdapter in project AnimeTaste by daimajia.

the class StartActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContext = this;
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
    mVideoList = (ListView) findViewById(R.id.videoList);
    mDrawerList = (ListView) findViewById(R.id.function_list);
    mDrawer = (LinearLayout) findViewById(R.id.drawer);
    mLayoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mCategoryList = (ListView) findViewById(R.id.category_list);
    mFooterView = mLayoutInflater.inflate(R.layout.load_item, null);
    mLoadProgress = (ProgressBar) mFooterView.findViewById(R.id.loading);
    mLoadText = (TextView) mFooterView.findViewById(R.id.load_text);
    mVideoList.addFooterView(mFooterView);
    mVideoList.setOnScrollListener(this);
    mDrawer.setOnTouchListener(this);
    View headerView = mLayoutInflater.inflate(R.layout.gallery_item, null, false);
    mVideoList.addHeaderView(headerView);
    mRecommendPager = (ViewPager) headerView.findViewById(R.id.pager);
    mRecommendPager.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            PointF downP = new PointF();
            PointF curP = new PointF();
            int act = event.getAction();
            if (act == MotionEvent.ACTION_DOWN || act == MotionEvent.ACTION_MOVE || act == MotionEvent.ACTION_UP) {
                ((ViewGroup) v).requestDisallowInterceptTouchEvent(true);
                if (downP.x == curP.x && downP.y == curP.y) {
                    return false;
                }
            }
            return false;
        }
    });
    mRecommendIndicator = (UnderlinePageIndicator) headerView.findViewById(R.id.indicator);
    if (getIntent().hasExtra("Success")) {
        init(getIntent());
    } else {
        Toast.makeText(mContext, R.string.init_failed, Toast.LENGTH_SHORT).show();
        finish();
    }
    mDrawerAapter = new SimpleAdapter(this, getDrawerItems(), R.layout.drawer_item, new String[] { "img", "title" }, new int[] { R.id.item_icon, R.id.item_name });
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_action_navigation_menu, R.string.app_name, R.string.app_name) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (mPreviousType != mType || mPreviousCategoryId != mCategoryId) {
                mCurrentPage = 1;
                mIsEnd = false;
                mVideoAdapter.removeAllData();
                mFooterView.findViewById(R.id.loading).setVisibility(View.VISIBLE);
                mFooterView.findViewById(R.id.load_text).setVisibility(View.INVISIBLE);
                triggerApiConnector();
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mPreviousType = mType;
            mPreviousCategoryId = mCategoryId;
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerList.setAdapter(mDrawerAapter);
    mDrawerList.setOnItemClickListener(this);
    ViewUtils.setListViewHeightBasedOnChildren(mDrawerList);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
    getSupportActionBar().setLogo(R.drawable.rsz_ab_icon);
    rateForUsOrCheckUpdate();
    showWhatsNew();
}
Also used : OnTouchListener(android.view.View.OnTouchListener) PointF(android.graphics.PointF) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) SimpleAdapter(android.widget.SimpleAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) MotionEvent(android.view.MotionEvent)

Example 3 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_frameworks_base by ResurrectionRemix.

the class HwTests method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String path = intent.getStringExtra("com.android.test.hwui.Path");
    if (path == null) {
        path = "";
    }
    setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
    getListView().setTextFilterEnabled(true);
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent)

Example 4 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_frameworks_base by ResurrectionRemix.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String path = intent.getStringExtra(EXTRA_PATH);
    if (path == null) {
        path = "";
    } else {
        // not root level, display where we are in the hierarchy
        setTitle(path);
    }
    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        ListFragment listFragment = new TestListFragment();
        listFragment.setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
        fm.beginTransaction().add(android.R.id.content, listFragment).commit();
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ListFragment(android.support.v4.app.ListFragment) SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent)

Example 5 with SimpleAdapter

use of android.widget.SimpleAdapter in project YourEyes by SevenLJY.

the class PoiSearchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_poisearch);
    sv_destination = (SearchView) findViewById(R.id.sv_destination);
    lv_result = (ListView) findViewById(R.id.lv_result);
    poiItems = new ArrayList<PoiItem>();
    listItems = new ArrayList<Map<String, String>>();
    //对搜索框的设置
    //设置不自动缩小为图标
    sv_destination.setIconifiedByDefault(false);
    //显示搜索按钮
    sv_destination.setSubmitButtonEnabled(true);
    longitude = 0;
    latitude = 0;
    latitudeStatus = 0;
    city = "";
    //初始化定位
    initLocation();
    startLocation();
    //搜索框搜索监听
    sv_destination.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {
            //点击搜索时触发,将搜索结果展示在ListView中
            for (int num = 0; num < listItems.size(); num++) {
                listItems.get(num).clear();
            }
            listItems.clear();
            if (city.length() != 0) {
                //city值仍为""时无意义,搜索所得位置不在本城市,该处处理为不予显示
                query = new PoiSearch.Query(s, "", city);
                //设置每页展示20个结果
                query.setPageSize(10);
                //设置查询页码
                query.setPageNum(0);
                poiSearch = new PoiSearch(PoiSearchActivity.this, query);
                //设置周边搜索的中心点以及半径,以定位的当前位置为中心点
                poiSearch.setBound(new PoiSearch.SearchBound(new LatLonPoint(latitude, longitude), 3000));
                poiSearch.setOnPoiSearchListener(new PoiSearch.OnPoiSearchListener() {

                    @Override
                    public void onPoiSearched(PoiResult poiResult, int i) {
                        //搜索结果在列表中显示
                        if (i == 1000 && poiResult != null) {
                            poiItems = poiResult.getPois();
                            for (PoiItem item : poiItems) {
                                listItem = new HashMap<String, String>();
                                listItem.put("title", item.toString());
                                listItem.put("content", item.getCityName() + item.getAdName() + item.getSnippet());
                                listItem.put("latitude", Double.toString(item.getLatLonPoint().getLatitude()));
                                listItem.put("longitude", Double.toString(item.getLatLonPoint().getLongitude()));
                                listItems.add(listItem);
                                item.toString();
                            }
                            adapter = new SimpleAdapter(PoiSearchActivity.this, listItems, R.layout.array_poiitems, new String[] { "title", "content" }, new int[] { R.id.tv_title, R.id.tv_content });
                            lv_result.setAdapter(adapter);
                        } else {
                            ToastUtil.show(PoiSearchActivity.this, "无搜索结果 请检查关键字");
                        }
                    }

                    @Override
                    public void onPoiItemSearched(PoiItem poiItem, int i) {
                    //搜索结果回调,暂时不需使用
                    }
                });
                poiSearch.searchPOIAsyn();
            } else {
                ToastUtil.show(PoiSearchActivity.this, "正在获取定位信息  请稍候");
            }
            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            //搜索框文字改变时触发,暂不做优化
            return false;
        }
    });
    /**
         * 为列表项单击事件添加监听
         * 单击相应列表项时跳转到导航界面并将目的地传至导航界面
         * */
    lv_result.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Bundle data = new Bundle();
            data.putDouble("latitude", Double.parseDouble(listItems.get(i).get("latitude")));
            data.putDouble("longitude", Double.parseDouble(listItems.get(i).get("longitude")));
            data.putDouble("myLatitude", latitude);
            data.putDouble("myLongitude", longitude);
            if (latitude == 0) {
                ToastUtil.show(PoiSearchActivity.this, "您的定位信息出错,请检查是否打开了GPS");
            } else {
                Intent intent = new Intent(PoiSearchActivity.this, BasicWalkNaviActivity.class);
                intent.putExtras(data);
                startActivity(intent);
            }
        }
    });
}
Also used : PoiResult(com.amap.api.services.poisearch.PoiResult) PoiItem(com.amap.api.services.core.PoiItem) LatLonPoint(com.amap.api.services.core.LatLonPoint) PoiSearch(com.amap.api.services.poisearch.PoiSearch) Bundle(android.os.Bundle) SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent) SearchView(android.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) LatLonPoint(com.amap.api.services.core.LatLonPoint) SearchView(android.widget.SearchView) AdapterView(android.widget.AdapterView) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SimpleAdapter (android.widget.SimpleAdapter)133 HashMap (java.util.HashMap)53 ListView (android.widget.ListView)39 Intent (android.content.Intent)33 Map (java.util.Map)33 View (android.view.View)28 ArrayList (java.util.ArrayList)28 AdapterView (android.widget.AdapterView)27 TextView (android.widget.TextView)25 ViewGroup (android.view.ViewGroup)14 ListAdapter (android.widget.ListAdapter)10 ImageView (android.widget.ImageView)9 Spanned (android.text.Spanned)6 TtsSpan (android.text.style.TtsSpan)6 MotionEvent (android.view.MotionEvent)6 Button (android.widget.Button)6 FrameLayout (android.widget.FrameLayout)6 Test (org.junit.Test)6 SuppressLint (android.annotation.SuppressLint)5 Context (android.content.Context)5