android横向滑动导航菜单,Android横向滑动导航菜单
1.效果图:喎�"https://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxoMyBpZD0="2项目地址">2.项目地址:https://github.com/lynnchurch/HorizontalScrollMenu.git3.使用示例代码:package com.example.hori
1.效果图:
喎�"https://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4NCjxoMyBpZD0="2项目地址">2.项目地址:
https://github.com/lynnchurch/HorizontalScrollMenu.git
3.使用示例代码:
package com.example.horizontalscrollmenusample;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.lynnchurch.horizontalscrollmenu.BaseAdapter;
import com.lynnchurch.horizontalscrollmenu.HorizontalScrollMenu;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity
{
private HorizontalScrollMenu hsm_container;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
public void initView()
{
hsm_container = (HorizontalScrollMenu) findViewById(R.id.hsm_container);
hsm_container.setAdapter(new MenuAdapter());
}
class MenuAdapter implements BaseAdapter
{
String[] names = new String[]
{ "菜单一", "菜单二", "菜单三", "菜单四", "菜单五", "菜单六", "菜单七" };
@Override
public List getMenuItems()
{
// TODO Auto-generated method stub
return Arrays.asList(names);
}
@Override
public List getContentViews()
{
// TODO Auto-generated method stub
List views = new ArrayList();
for (String str : names)
{
View v = LayoutInflater.from(MainActivity.this).inflate(
R.layout.content_view, null);
TextView tv = (TextView) v.findViewById(R.id.tv_content);
tv.setText(str);
views.add(v);
}
return views;
}
}
}
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)