Android intent 页面跳转

slidemenu_layout 部分列表(点击帮助跳转到user_help_layout.xml页面)

page1

//slidemenu_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:orientation="vertical">

   <TextView
        android:id="@+id/user_manual_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginStart="10dp"
        android:drawableStart="@mipmap/icon_note4_nor"
        android:drawablePadding="10dp"
        android:gravity="center_vertical"
        android:text="@string/user_manual"
        android:textColor="#333333"
        android:textSize="@dimen/text_content_big" />

    <TextView
        android:id="@+id/user_help_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginStart="10dp"
        android:drawableStart="@mipmap/icon_note4_nor"
        android:drawablePadding="10dp"
        android:gravity="center_vertical"
        android:text="@string/user_help"
        android:textColor="#333333"
        android:textSize="@dimen/text_content_big" />

    <TextView
        android:id="@+id/emeet_product_layout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginStart="10dp"
        android:drawableStart="@mipmap/icon_note4_nor"
        android:drawablePadding="10dp"
        android:gravity="center_vertical"
        android:text="@string/emeet_product"
        android:textColor="#333333"
        android:textSize="@dimen/text_content_big" />
</LinearLayout>
//UserCenterActivity.java
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.slidemenu_layout);
        
        ButterKnife.bind(this);//需要引入ButterKnife框架
    }
    @OnClick({R.id.user_help_layout,R.id.user_manual_layout,R.id.emeet_product_layout})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.user_help_layout:
                toUserHelpActivity();
                break;
            case R.id.user_manual_layout:
                toUserManualActivity();
                break;
            case R.id.emeet_product_layout:
                toEmeetProductActivity();
                break;
        }
    }
     private void toUserHelpActivity() {
        showActivity(UserHelpActivity.class);
    }
    private void toUserManualActivity() {
        showActivity(UserManualActivity.class);
    }
    private void toEmeetProductActivity() {
        showActivity(EmeetProductActivity.class);
    }

	public void showActivity(Class<?> cls) {
        Intent intent = new Intent(this, cls);
        startActivity(intent);
    }

user_help_layout.xml页面:
(跳转到这个页面,并且点击对应item,提示不同的信息)

user_help_layout

//user_help_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <!--  帮助列表 -->
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="user_help_layout"
        android:id="@+id/helpList"
    />
</LinearLayout>
//UserHelpActivity.java
public class UserHelpActivity extends BaseActivity  {
    private ListView helpList;
    private ArrayAdapter<String> arr_adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_help_layout);
        helpList = (ListView) findViewById(R.id.helpList);

        //准备列表数据
        String helpStringDatas1 = getResources().getString(R.string.Operating_Guide);
        String helpStringDatas2 = getResources().getString(R.string.How_to_Use_EMEET);
        String helpStringDatas3 = getResources().getString(R.string.Help_Center);
        String helpStringDatas4 = getResources().getString(R.string.Contact_us);

	    //String arrData[] = {"快速操作指南","如何使用 EMEET AI APP","EMEET帮助中心","联系我们"};
        String arrData[] = {helpStringDatas1,helpStringDatas2,helpStringDatas3,helpStringDatas4};
     

        //数据适配器
        arr_adapter = new ArrayAdapter<>(this,android.R.layout.simple_list_item_1,arr_data);

        //加载适配器
        helpList.setAdapter(arr_adapter);

        //监听itme点击事件
        helpList.setOnItemClickListener ( new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int i, long l) {
                String str = parent.getItemAtPosition(i).toString();
                Toast.makeText(UserHelpActivity.this, "你点击的是"+str, Toast.LENGTH_SHORT).show();;
            }
        });
    }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值