zoukankan      html  css  js  c++  java
  • eatwhatApp开发实战(十)

    android应用中,很少有一个activity的app,这次我们设置一个activity,通过listview的点击跳转并显示对应的商店信息。

    首先创建类ShopInfoActivity,对应设置其xml文件属性:

    java:

    public class ShopInfoActivity extends Activity{
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_shop_info);
    	}
    }
    

    xml:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >
    
        <TextView 
            android:id="@+id/tv_text_shop_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="店名:"
            android:textSize="20sp"/>
    </RelativeLayout>

    接下来实现点击跳转的: 

    //意图
    Intent it = new Intent();
    //跳转activity
    it.setClass(MainActivity.this, ShopInfoActivity.class);
    //意图开启
    startActivity(it);
    

    在AndroidManifest.xml中注册ShopInfoActivity:

    <activity
        android:name="com.appdemo.eatwhat.ShopInfoActivity">
    </activity>
    

    这样,就可以点击跳转到另一个Activity。

  • 相关阅读:
    1.1、html概述和基本结构
    几个常用的产品原型设计工具
    Redis 3. 与python交互
    Redis 2.2、主从配置
    Redis 2.1、发布订阅
    Redis 1.6、zset
    Redis 1.5、set
    Redis 1.4、list
    php实现手机拍照上传头像功能
    php获取文件mime类型Fileinfo等方法
  • 原文地址:https://www.cnblogs.com/superdo/p/5155917.html
Copyright © 2011-2022 走看看