Android第十六期 - 侧边栏SlidingMenu支持自定义左右
代码已经整理好,效果如下图: 本文转自 吴雨声 51CTO博客,原文链接:http://blog.51cto.com/liangxiao/1553349,如需转载请自行联系原作者
未来的我,希望能看到这篇文章的时候,想一想什么都走过来了,还有什么走不得呢,无论何时何地,不要停下学习的脚步。
mainactivity篇
package com.example.qingdan;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void click1(View v) {
//【1】创建意图对象
Intent intent =new Intent();
//【2】设置拨打电话的动作
intent.setAction(Intent.ACTION_CALL);
//【3】设置拨打的数据
intent.setData(Uri.parse("tel:"+119));
//【4】开启Activity
startActivity(intent);
}
//隐式意图
public void click2(View v){
//[1]创建意图对象
Intent intent=new Intent();
//[2]设置跳转的动作
intent.setAction("com.iteheima.comm");
//设置category
intent.addCategory("android.intent.category.DEFAULT");
//设置数据
//intent.setData(Uri.parse("itheima:"+110));
//设置数据类型
//intent.setType("aa/bb");//调用setdate会自动清除setdata
//所以出现此种情况,我们应该调用如下编程
intent.setDataAndType(Uri.parse("itheima:"+110), "aa/bb");//itheima是data中已经配置好了的,所以上述同理只能用‘tel’
//开启activity
startActivity(intent);
}
//显示意图
//点击按钮跳转到 TestActivity
public void click3(View v) {
//[1]创建意图对象 意图就是我要完成一件事
Intent intent = new Intent(this,test3activity.class);
//[2]设置包名和类名 packageName:当前应用的包名
//intent.setClassName("com.itheima.newactivity", "com.itheima.newactivity.Test3Activity");
//[3]开启Activity
startActivity(intent);
}
}
test3activity篇
package com.example.qingdan;
import android.os.Bundle;
import android.app.Activity;
public class test3activity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO 自动生成的方法存根
super.onCreate(savedInstanceState);
//加载布局
setContentView(R.layout.activity_test);
}
}
testactivity篇
package com.example.qingdan;
import android.app.Activity;
import android.os.Bundle;
public class testactivity extends Activity{
//当Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO 自动生成的方法存根
super.onCreate(savedInstanceState);
//加载布局
setContentView(R.layout.activity_test);
}
}
layout——activitymain篇
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click1"
android:text="拨打电话"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click2"
android:text="跳转到activity"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="click3"
android:text="跳转到activity"/>
</LinearLayout>
activitymain——test3篇
<?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:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="wo shi test"
/>
</LinearLayout>
activitymain-test篇
<?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:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="我是testActivity333" />
</LinearLayout>
android manifest篇
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.qingdan"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.qingdan.MainActivity"
android:icon="@drawable/head1"
android:label="我是第二个页面" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.qingdan.testactivity"
android:icon="@drawable/head2"
android:label="我是第一个页面" >
《!----》主入口》
<intent-filter>
<action android:name="com.iteheima.comm" />
<data android:scheme="itheima"
android:mimeType="aa/bb"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
《!我们可以创建出多个过滤器,只要,前面name,category能匹配到就行了,有一个就行哪怕data改变也可以》
<intent-filter>
<action android:name="com.iteheima.comm" />
<data android:scheme="itheima"
android:mimeType="aa/bb"
/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--配置Activity3 -->
<activity android:name="com.example.qingdan.test3activity"></activity>
</application>
</manifest>
本文转自眉间雪 51CTO博客,原文链接:http://blog.51cto.com/13348847/1980916,如需转载请自行联系原作者
微信关注我们
转载内容版权归作者及来源网站所有!
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。
Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。
Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。
Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。