目前我正在使用扩展列表中孩子的自定义版式, 其中包括两个不同的文本视图和一个图像视图。 而且它每次总是有一个孩子。 我可以在适配器中找到点击听筒, 但无法在活动中得到这个 。
我也尝试在“ChildClick”(ChildClick ())方法上获得点击听众活动,
我在不同的活动中使用这个适配器, 所以我想让点击的听众在活动本身的文字视图中看到一个文字视图 。
请提出任何建议。
目前我正在使用扩展列表中孩子的自定义版式, 其中包括两个不同的文本视图和一个图像视图。 而且它每次总是有一个孩子。 我可以在适配器中找到点击听筒, 但无法在活动中得到这个 。
我也尝试在“ChildClick”(ChildClick ())方法上获得点击听众活动,
我在不同的活动中使用这个适配器, 所以我想让点击的听众在活动本身的文字视图中看到一个文字视图 。
请提出任何建议。
在布局文件中添加了 and mid: onClick="textClickHandler" & gt;
, 并将以下的听众纳入我的活动:
public void textClickHandler(View view){
if(view.getId() == R.id.textMore){
Toast.makeText(mContext, "More Text Clicked.", Toast.LENGTH_LONG).show();
}
}
您无法设置 View
上的听众, 即 activity
(如果我能理解您想要做什么的话)。 一种方法是:
boolean
value that you set when you instantiate the adapter(This will tell you if the adapter belongs to an Activity
where the TextView
should have a listener(for true
, for example). If the value is false
then you ll make sure not to set a listener on the TextView
).TextView
(only if the previous value was true
, for other activities you ll simple ignore this part) in the getChildView
method of your custom adapter.onClick
method for that view s OnCLickListener
use the Context
that you pass in the constructor of your custom adapter. Cast it to the desired activity and use it as you want. A more elegant way of doing this would be to let the desired Activity
implement a custom interface(to notify you when the TextView
was clicked). Then in the adapter make a field with the type of that interface that you ll set to point to your Activity
when you instantiate the listener. When the TextView
is clicked call the methods of that field above and notify the Activity
that something happen and it should do some stuff.I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...