在Eclipse中用Scala语言开发Android应用
1、下载安装 Eclipse Classic 3.7.2
注:下载JDK与Android SDK的事我就不详述了,有问题可以问我
2、安装Android ADT Plugin
安装地址:https://dl-ssl.google.com/android/eclipse/
3、安装Scala IDE
安装地址:http://download.scala-ide.org/releases-29/milestone/site/
4、安装AndroidProguardScala
安装地址:https://androidproguardscala.s3.amazonaws.com/UpdateSiteForAndroidProguardScala
5、创建Android Project
6、Add Scala Nature
在android项目上点右键,Configure->Add Scala Nature
7、Add AndroidProguardScala Nature
在android项目上点右键,Add AndroidProguardScala Nature
8、调整Java Build Path顺序(重要)
注意把两个scala的lib,移动到Android上方
9、把Java的Activity类替换为scala的Activity类
package org.noahx.scalaandroid import android.app.Activity import android.os.Bundle import android.widget.Button import android.widget.TextView import android.view.View class ScalaAndroidActivity extends Activity { override protected def onCreate(savedInstanceState: Bundle) = { super.onCreate(savedInstanceState) setContentView(R.layout.main) val text = findViewById(R.id.text1).asInstanceOf[TextView] val button = findViewById(R.id.button1).asInstanceOf[Button] button.setOnClickListener(new View.OnClickListener() { def onClick(v: View) = { text.setText("hello scala!!!") } }) } }
注:修改完layout,把project clean一下
10、运行效果
相关推荐
匆匆那些年 2020-10-15
TheBigBlue 2020-07-28
shenwenjie 2020-07-07
muhongdi 2020-07-07
waitwolf 2020-07-08
yunfenglee 2020-07-08
yunfenglee 2020-07-08
kekeromer 2020-07-08
匆匆那些年 2020-07-07
liqinglin0 2020-07-05
TheBigBlue 2020-07-05
kekeromer 2020-06-13
zhixingheyitian 2020-06-08
TheBigBlue 2020-06-06
liqinglin0 2020-06-01
liqinglin0 2020-06-01
yunfenglee 2020-05-30
MICKEYSTUDY 2020-05-28
muhongdi 2020-05-19