从开始在Android中的视图的活动? [英] Starting an activity from a view in android?

查看:106
本文介绍了从开始在Android中的视图的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方式开始从视图的活动?我有一个使这些菜单按钮,当他们点击一个特定的按钮(被困在一个onTouch事件),我要开始的这个风景独好点击的活动。

这似乎从我的观点startActivity方法有uncallable。所以这让我相信,有没有办法做到这一点,在这种情况下,我想我是问,我该怎么办这里的时候,我想这个菜单有动画可绘制一个视图,可以接触到了解按钮是pressed知道什么活动启动?

我一直在寻找,并没有什么似乎符合我所期待的。我怀疑,因为我无法找到它,它可能打破惯例以某种方式与在这种情况下,什么是正确的方式做到这一点?

我还有一个活动启动这个凉爽的滚动瓦片地图视图。当用户点击一个特定的瓷砖,我想加载了一个完全不同的观点的基础上tileID(甚至活动不知道,我需要)点击。这种新的视图或活动将显示在单元格被点击(想像与细胞中的地图中的所有项目,每个小区都有的东西在里面。当用户点击该单元格,然后一个新的观点恰巧说明这一切的东西一样酷绘区域,喜欢它的单元格中的放大)。

我想我需要同样的事情,当用户在我的滚动地图视图和他们推先降后升,我得到他们点击哪些细胞,并用它来初始化将推出显示放大的状态下活动(使用了一种新的观点我怀疑通过可绘制)的事情

解决方案
  

有没有办法来启动一个活动   从视图?

可以说,查看应该告诉承载它开始活动了活动,通过注册的回调方法。我不是一个球迷,你在这里描述的code组织(但是,不可否认,单纯的描述为主)。

不过,如果你真的想拥有查看启动该活动,有查看呼叫的getContext()。startActivity()

Is there a way to start an activity from a view? I have this nice view that renders these menu buttons and when they click a particular button (Trapped in an onTouch event) I want to start the "clicked" activity.

It seems that there from my view startActivity method is uncallable. So that leads me to believe that there is no way to do this, in which case I guess I am asking, what do I do here when I want this menu to have a view that animates drawables and can get touches to know what "button" was pressed to know what activity to start?

I have been searching and nothing seems to fit what I am looking for. I suspect since I cannot find it that it probably breaks convention in some way and in which case, what is the proper way to do this?

I have another Activity that starts this cool scrolling tile map view. When the user clicks on a specific tile I would like to load up an entirely different view (maybe even activity not sure which I need) based on the tileID clicked. This new View or activity would show all the items in the cell that was clicked (imagine the map with cells , each cell has stuff in it. When the user clicks on the cell then a new view happens that shows all this stuff as cool drawables, like it "zoomed in" on the cell).

I would think I need the same thing, when the user is inside my scrolling map view and they push down then up I get what cell they clicked on and use that to initialize the activity that will launch showing the zoomed in state of things (via drawables using a new kind of view i suspect)

解决方案

Is there a way to start an activity from a view?

Arguably, the View should tell the Activity that hosts it to start an activity, via a registered callback method. I am not a fan of the code organization you have described here (but, admittedly, based solely on the description).

However, if you really want to have the View start the activity, have the View call getContext().startActivity().

这篇关于从开始在Android中的视图的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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