在我的主要观点中,我有:
public class PlayersActivity extends Activity {
ViewFlipper flipper;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.playercontainer);
flipper = (ViewFlipper) findViewById(R.id.flipper);
}
}
Run Code Online (Sandbox Code Playgroud)
有了这个观点:
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include android:id="@+id/first" layout="@layout/first" />
<include android:id="@+id/second" layout="@layout/playerdetailsview" />
</ViewFlipper>
Run Code Online (Sandbox Code Playgroud)
它正确地显示了第一个视图,但是我希望它连接到java类,所以我创建了一个FirstActivity类,我可以在第一个视图中控制所有组件,但是如何将first.xml布局与FirstActivity java类相连?
我正在尝试声明我在不同的类 B 中编写的类 A 的静态对象,如下所示:
class A // just an example
{
int x;
public:
A(){ x = 4; }
int getX() { return x; }
};
class B
{
static A obj1; // <- Problem happens here
public:
static void start();
};
int main()
{
B::start();
}
void B::start()
{
int x = obj1.getX();
}
Run Code Online (Sandbox Code Playgroud)
我想要实现的是在(4)int x中B::start()达到相等。int xclass A
在过去的一个小时里,我尝试在谷歌上搜索所有这些,我所了解的只是 C++ 不允许静态对象的声明。那是对的吗?
如果是这样,这是我的问题。我怎样才能得到相同的结果?我有哪些可用的解决方法?请记住,我的其余代码依赖于类 B 中的函数是静态的。
错误
错误 LNK2001:无法解析的外部符号“私有:静态类 AB::obj1”
谢谢!
我正面临一个问题.
我有两个Button对象.
ButtonA ButtonB
需求:-
当我按下ButtonA 按钮的颜色应该改变它应该保持相同,直到我点击ButtonB.
点击ButtonB相同的东西应该是工作即为ButtonA
if (v == btn)
{
btn.setBackground(mActivity.getResources().getDrawable(R.drawable.button_color_chnager));
}
Run Code Online (Sandbox Code Playgroud)
XML:
<item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/ic_launcher" />
Run Code Online (Sandbox Code Playgroud) 在我的tvOS应用程序中,我有一个搜索页面,位于顶部a Search Bar和a Table View下面,最后列出了结果.
当我们关注searchBar并且用户按下Siri的声音时,结果将被插入搜索栏(如预期的那样).然而,当用户向下滚动结果并且无法找到他们正在寻找的内容时,他们必须向上滚动(一直向上)到searchBar再次使用Siri.
如果用户searchBar在未关注时尝试使用Siri,则全球Siri开始在不同的应用程序中查找结果(这不是我想要的)
如何在搜索页面上将searchBar设置为Siri的全局焦点?
说实话,我不知道该如何去做..
在AppDelegate.swift中调用一个函数来创建Search View Controller并将其添加到Tab Bar Controller.
我已经考虑过尝试preferedFocusView,但在阅读完文档之后,我怀疑它会起作用.
func configueSearchController() -> UIViewController {
let storyboard = UIStoryboard(name: "Search", bundle: nil)
guard let searchResultsController = storyboard.instantiateViewController(withIdentifier: SearchViewController.storyboardIdentifier) as? SearchViewController else {
fatalError("Unable to instatiate a SearchResultViewController from the storyboard.")
}
/*
Create a UISearchController, passing the `searchResultsController` to
use to display search results.
*/
let searchController = UISearchController(searchResultsController: searchResultsController)
searchController.searchResultsUpdater = searchResultsController
searchController.searchBar.placeholder …Run Code Online (Sandbox Code Playgroud) 我正在创建一个简单的闪存卡应用程序,如下图所示:
我想要向后滑动,就像这样:
要做到这一点,onBack(index: Int)我需要在刷卡时调用(为了更新显示的卡):
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var flashCardLabel: UILabel!
// Populate initial content
let content = ["Lorem", "Ipsum", "Dolor", "Sit"]
// Index of where we are in content
var index = 0
override func viewDidLoad() {
super.viewDidLoad()
}
// Label text based on index
func setLabelToIndex() {
flashCardLabel.text = content[index]
}
// Go back
@IBAction func back(_ sender: Any) {
if index > 0 {
index = index - 1
setLabelToIndex()
} …Run Code Online (Sandbox Code Playgroud) 我想从Firebase中删除当前用户.已验证的用户被删除但是,我无法删除数据库中该用户的数据.我究竟做错了什么?
这是我的删除用户方法....
FIRAuth.auth()?.signIn(withEmail: (emailTextField?.text)! , password: (passwordTextField?.text)!, completion: { (user, error) in
if error == nil {
print("User Authenticate!!!")
let user = FIRAuth.auth()?.currentUser
user?.delete(completion: { (error) in
if error != nil {
print("Error unable to delete user")
} else {
DataService.ds.deleteCurrentFirebaseDBUser()
KeychainWrapper.standard.removeObject(forKey: KEY_UID)
self.performSegue(withIdentifier: "goToLogin", sender: nil)
}
})
} else {
//Password was wrong, unable to authenicate user. Data is not updated
print("!!!ALERT!!! Unable to authenticate user")
let alert = UIAlertController(title: "Incorrect Password", message: "Please re-enter your password", preferredStyle: …Run Code Online (Sandbox Code Playgroud) ios firebase swift firebase-authentication firebase-realtime-database
我正在尝试从 firebase 数据库中检索数据,但是当我运行代码时,它什么也没显示,尽管没有显示错误
我从 Firebase 手册中得到了这段代码,顺便说一句,我很确定路径是正确的
let ref = FIRDatabase.database().reference()
ref.child("users").child("user").child(username).observeSingleEvent(of: .value, with: { (snapshot) in
// Get user value
let value = snapshot.value as? NSDictionary
let score = value?["score"] as? String ?? ""
print(score)
// ...
}) { (error) in
print(error.localizedDescription)
}
Run Code Online (Sandbox Code Playgroud)
JSON
{
"users" : {
"user" : {
"e1410kokeZS8xv81J1RzhN4V2852" : {
"email" : "aaaa@gmail.com",
"score" : 0,
"username" : "Afnan"
},
"jPx8XJ3Q9AazDM7qIOhz02PBfh22" : {
"email" : "aaaa@ggg.com",
"score" : 13,
"username" : "ghhh"
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 当我按下后退按钮时,我需要调用一个函数.优选地,不必创建另一个按钮
如何在服务器上传文件后创建回调?
我希望在JS函数调用后在服务器上上传文件.我想调用该函数addDownload,在此函数完成后,调用下一个javascript函数.我怎样才能做到这一点?
我有以下源代码:
HTML:
<form id="imageform" method="post" enctype="multipart/form-data" action="actions/downloadsadd.php">
<strong>File: </strong><input name="photoimg" id="photoimg" style="width: 100px;" type="file" />
Select Image: <br />
<div id="divPreview"></div>
</form>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
addDownload: function ()
{
$("#divPreview").html('');
$("#divPreview").html('<img src="Images/loader.gif" alt="Uploading...."/>');
$("#imageform").ajaxForm(
{
target: '#divPreview'
}).submit();
},
Run Code Online (Sandbox Code Playgroud)
PHP - downloads.php:
public function addDownloads() {
$db = new DB();
$db->connect();
$path = "../../images/upload/files/";
$valid_formats = array("php", "phtml", "php3", "php4", "js", "shtml", "pl", "py", "html", "exe", "bat", "htm", "sql");
if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
$name = …Run Code Online (Sandbox Code Playgroud) 我想在C#中使用Java样式多态.可能吗?
这是一个不编译的例子
using System;
namespace HelloWorld
{
public class Program
{
public static void Main (string[] args)
{
Triangle triangle = new Triangle(2);
Square square = new Square(3);
printID(square);
}
public void printID(Shape s){
Console.WriteLine ("id is " + s.id);
}
}
public class Shape{
public int id;
}
public class Triangle: Shape{
float b;
float height;
float area(){
return b*height/2;
}
public Triangle(int k){
id=k;
}
}
public class Square: Shape{
float side;
float area(){
return side*side;
}
public …Run Code Online (Sandbox Code Playgroud)