我正在动态列表视图显示下面选择的特定项目。任何人都建议我怎么可能?我在这里证明了快照。
我的代码如下。
root.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// im++;
final ListPopupWindow listPopupWindow = new ListPopupWindow(getActivity());
ArrayList<String> a=new ArrayList<String>();
a.add("a");
a.add("b");
listPopupWindow.setAdapter(new ArrayAdapter(
getActivity(),
R.layout.raw_comment,a.size()));
listPopupWindow.setAnchorView(v);
listPopupWindow.show();
//showAlertDialog(getActivity(), "List display 1");
}
});
您的回答将不胜感激
答案 0 :(得分:3)
试试这个
import UIKit
import NotificationCenter
class TodayViewController: UIViewController, NCWidgetProviding {
@IBOutlet var TextToWidget: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view from its nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func widgetPerformUpdateWithCompletionHandler(completionHandler: ((NCUpdateResult) -> Void)) {
let ShareDefaults = NSUserDefaults(suiteName:"group.St33v3n.TextOnWidget")
self.TextToWidget.text = ShareDefaults?.objectForKey("StringKey") as? String
completionHandler(NCUpdateResult.NewData)
}
}
答案 1 :(得分:0)
例如:
findViewById(R.id.btn).setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//use MotionEvent event : getX() and getY() will return your pressing
location in the button.
}
});