[英]How to achieve this navigation menu in android
I need to achieve a navigation menu such as this: 我需要实现一个这样的导航菜单:
I don't want to use Navigation drawer since I am already using it for other purposes. 我不想使用导航抽屉,因为我已经将其用于其他用途。
Let me explain a little bit the situation: 让我解释一下情况:
I have a navigation drawer that shows a listview with some options. 我有一个导航抽屉,显示带有某些选项的列表视图。 When user clicks on an option, navigation drawer disappear and in may content view should show some buttons with the look & feel as the image above.
当用户单击一个选项时,导航抽屉消失,并且在内容视图中应显示带有外观的按钮,如上图所示。
When a button is pressed, a new view (corresponding to button selection) should slide in from the right. 当按下按钮时,应从右侧滑动一个新视图(对应于按钮选择)。
How can I achieve this? 我该如何实现? I have not found a good resource for this.
我还没有找到一个很好的资源。
Thanks Jaime 谢谢海梅
I have done it finally by using a ListView. 我终于通过使用ListView做到了。
This is the code,and I can assure it is not confusing, and in fact, this is done in every android app: 这是代码,我可以保证它不会混淆,实际上,这是在每个android应用程序中完成的:
public void DrawAreas() {
final ListView areaView = (ListView) _activity.findViewById(R.id.area_list);
ArrayAdapter<TdcArea> areas = new ArrayAdapter<TdcArea>(_activity.getApplicationContext(),
android.R.layout.simple_list_item_1,
_system.getAreas()) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView text = (TextView) view.findViewById(android.R.id.text1);
text.setTextColor(Color.BLACK);
Drawable icon = ContextCompat.getDrawable(_activity.getApplicationContext(), R.drawable.chevron_red);
text.setCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);
return view;
}
};
areaView.setAdapter(areas);
areaView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TdcArea area = (TdcArea) areaView.getItemAtPosition(position);
Intent intent = new Intent(_activity.getApplicationContext(), FormActivity.class);
intent.putExtra("AREA", area);
_activity.startActivity(intent);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.