eatwhatApp开发实战(十三)】的更多相关文章

这次内容,我们就项目中添加商店名称的EditText进行修改,让添加按钮随着edittext的内容而改变. 上代码,首先是xml文件上对两个控件的修改: <RelativeLayout android:id="@+id/et_relative" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:i…
在实战二中我们在eatwhatApp上增加了“添加店铺的功能”.接下来,我们来将添加的店铺显示出来,这里我们用到控件--ListView. 先上演示图: 首先,我们先设置布局: <RelativeLayout android:id="@+id/et_relative" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button…
上期,我们做了个小app“eatwhat”,接下来每期都会为其添加新的功能.本期,我们为店铺增加添加店铺的功能. 还是先设置个布局: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:id="@+id/add_shop_btn" android:layout_width…
开发背景: 当你想用抛硬币来决定事情的时候,那么硬币抛起的瞬间,你就有答案了.一样的,吃啥?eatwhat点开,按钮一点,你就可以知道你中午要吃啥. 话不多说,项目开发走起 ADT点开,New==>Android Application Project ==> 首先确定布局,第一版我们就做简单的功能,视图中有两个控件,一个文本(TextView)用来输出店家名称,一个按钮(Button)用来让用户点击进行店家名称的随机切换.在android开发中有两种方式来实现布局,今天我们先讲用配置文件.x…
之前我们就输入框EditText做了优化,而这次,我们为app添加拨打电话的功能. 首先是布局,将activity_shop_info.xml中对应的电话那一栏进行重新设计: <RelativeLayout android:id="@+id/ll_tel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below…
上次我们介绍了跳转activity并且实现传值的功能,今天我们来实现双击返回键退出app的功能,上代码: 这里我们有两种方式去实现点击事件: 第一种方式: /** * 返回键的监听(系统提供的) */ @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); } 第二种方式: @Override public boolean onKeyDown(int key…
之前我们实现了点击item项跳转activity,接下来我们再其基础上添加参数的传递. 在MainActivity里面的onItemClick()中: String name = shopList.get(position).getName(); //意图 Intent it = new Intent(); //bundle对象 Bundle类用作携带数据,它类似于Map,用于存放key-value名值对形式的值. Bundle mBundle = new Bundle(); mBundle.p…
android应用中,很少有一个activity的app,这次我们设置一个activity,通过listview的点击跳转并显示对应的商店信息. 首先创建类ShopInfoActivity,对应设置其xml文件属性: java: public class ShopInfoActivity extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated m…
之前我们为app在item项上添加了点击出现修改对话框,对店名进行修改的功能,其中我们会发现我们点击item和点击item上的按钮会有点击冲突.这次我们来修正下这个问题,同时介绍item项的长按点击OnItemLongClickListener(). 解决这个问题只需要修改对应item的xml文件上的两个属性,首先是item的布局上的设置: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android&q…
在App中增,删功能都有了,这次我们来做改的功能.在项目中点击items项时对对应的条目中的商店名称进行修改. 点击items跳出一个对话框,里面包含了输入框.修改按钮和取消按钮: AlertDialog.Builder builder = new Builder(MainActivity.this); builder.setTitle("删除?"); final EditText et = new EditText(MainActivity.this); builder.setVie…