如何从Android的一个按钮,只需点击一下做两次手术 [英] how to do two operations from a single click of a button in android

查看:97
本文介绍了如何从Android的一个按钮,只需点击一下做两次手术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我已经创建了一个应用程序。我已经有一个编码找到一个地方的经度和纬度。但在编码我有按钮,单击该按钮时,得到的值显示

hi i have created an app. I already have a coding to find the latitude and longitude of a place. But in that coding i have button and when the button is clicked the values get displayed

在我的应用程序我有一个名为启动按钮,当我点击按钮,它移动到一个新的一页。
在该页面我已经把两个布局。在一个布局我已经把一些的TextView和编辑文本数据与OK按钮。在其它布局我把经纬度的编码。

In my app i have a button named start, when i click the button it moves over to a new page. In that page i have placed two layouts. In one layout i have placed some textview and edit text data with a ok button. In the other layout i have placed the coding of latitude and longitude.

现在,当我点击开始按钮,新的页​​面必须获得打开,同时当前的纬度和经度必须得到显示。

Now when i click the start button the new page must get opened and at the same time the current latitude and longitude must get displayed.

请给予帮助我在同一个页面上同时执行的操作.......

pls give help me in performing both the operations in the same page.......

推荐答案

您不需要的AsyncTask。你只需要更新您在获取信息loadCoords()的意见;

You don't need AsyncTask. You just have to update your views with information you obtain in loadCoords();.

尝试是这样的:

  Coords coords = loadCoords();
  super.onCreate(savedInstanceState);        
  setContentView(R.layout.add);
  t1 = (TextView) findViewById(R.id.t1);
  t1.setText(coords.getLatitude());

P.S。只是一个点:Java的会议通知:在驼​​峰名称的方法,这样的:loadCoords() - 第一个字母总是很小

P.S. Just a point: Java Convention advices you to name methods in Camel Case, like this: loadCoords() - the first letter is always small.

这篇关于如何从Android的一个按钮,只需点击一下做两次手术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆