我已经创建了一个脚本,可以在插入时自动安装USB设备和cdrom驱动器.我一直在尝试使用autofs(请参阅https://superuser.com/questions/605896/automount-usb-pen-drive -and-cdrom-drive-on-plugin)但现在尝试使用在启动时运行的脚本.
我认为逻辑是合理的,但我得到了 line 13: [: missing ']'
该脚本是:
#!/bin/bash
while true
do
if [ -b /dev/sda1 ]
then
mkdir /media/usb
mount /dev/sda1 /media/usb
while [ -b /dev/sda1]; do
sleep 2
done
umount /media/usb
rmdir /media/usb
fi
if [ -b /dev/cdrom ]
then
mkdir /media/cdrom
mount /dev/sda1 /media/cdrom
while [ -b /dev/cdrom]; do
sleep 2
done
umount /media/cdrom
rmdir /media/cdrom
fi
sleep 5
done
Run Code Online (Sandbox Code Playgroud)
然后使用rc.local启动脚本 ./path/to/script&
目前我有这个代码:
ArrayList<String> items = new ArrayList<String>();
AssetManager assetManager = getApplicationContext().getAssets();
try {
items.addAll(Arrays.asList(assetManager.list("")));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
这给了我资产文件夹中所有文件名的arraylist.但是我需要对此进行过滤,以便arraylist只有具有.txt扩展名的文件的文件名,然后从每个项目名称中删除.txt.
所以当前的代码会导致:
test.txt
pi.txt
sounds
hippo.png
square.xml
seven.txt
Run Code Online (Sandbox Code Playgroud)
但当我需要时,arraylist的内容将是:
test
pi
seven
Run Code Online (Sandbox Code Playgroud) 我将下面的UITableViewController作为searchResultsController附加:
import UIKit
import MapKit
class LocationSearchTable : UITableViewController {
var matchingItems:[MKMapItem] = []
var mapView: MKMapView? = nil
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
}
}
extension LocationSearchTable : UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController){
guard let mapView = mapView,
let searchBarText = searchController.searchBar.text else { return }
let request = MKLocalSearchRequest()
request.naturalLanguageQuery = searchBarText
request.region = mapView.region
let search = MKLocalSearch(request: request)
search.start { response, _ in
guard let response = response else …Run Code Online (Sandbox Code Playgroud) 我有以下方法,执行时给出错误:
11-09 12:11:17.578:E/AndroidRuntime(21018):引起:android.database.sqlite.SQLiteException:没有这样的列:happy(代码1):,同时编译:select*from Bank where english = happy
方法是:
public boolean BankHas(Word currentWord) {
openDataBase();
Cursor cursor = myDataBase.rawQuery("select * from Bank where english = " + currentWord.english, null);
return cursor.moveToFirst();
}
Run Code Online (Sandbox Code Playgroud)
我的餐桌计划:
CREATE TABLE `Bank` (
`english` TEXT
);
Run Code Online (Sandbox Code Playgroud) 我有一个div,我需要隐藏在选项中选择一个选项,下面是我当前的HTML:
Type:<select name="Type" id="Type">
<option value="choice">Multiple choice</option>
<option value="image">Image/Video</option>
<option value="click">Click Image</option>
</select><br>
<div id="answers">
Correct Answer:<input type="text" name="answer"><br>
Wrong Answer 1:<input type="text" name="wrong1"><br>
Wrong Answer 2:<input type="text" name="wrong2"><br>
Wrong Answer 3:<input type="text" name="wrong3"><br>
</div>
Run Code Online (Sandbox Code Playgroud)
所以我需要的是当选择值为"click"的选项时,隐藏id为"answers"的div,如果选择了其他选项,则应显示此div.
我相信这可以用javas圆顶
我的应用程序在getActionBar()上使用android 4.4及更低版本从研究中返回null,因此我可以看到这是因为我的应用程序使用的是Android 5的材质主题和旧版本的AppCompat.
但是我无法看到修复返回null问题,或者让getSupportActionBar()正常工作,下面是我的代码,需要更改什么,以便我可以在较旧的android上使用getActionBar/getSUpportActionBar但仍然使用5上的材质主题.
我的活动:
public class MapsActivity extends ActionBarActivity implements LocationListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
...
mDrawerLayout.setDrawerListener(mDrawerToggle);
toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
if (toolbar != null)
{
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setElevation(0); // or other
}
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
V21/style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- your app's theme inherits from the Material theme -->
<style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<!-- Main theme colors -->
<!-- your app branding color for the app bar …Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用Facebook SDK,我目前有一个拥有自己的登录系统的应用程序,用户输入他们的电子邮件和密码,然后应用程序检查mysql数据库以找到用户.如果用户是他们,则返回用户信息并将其记录到应用程序中.
我想要做的是允许用户只需按下Facebook按钮,让Facebook SDK返回链接到他们的Facebook帐户的用户电子邮件.然后,我可以在我的数据库中搜索该电子邮件并记录用户或为他们创建一个帐户,如果他们不是该电子邮件的帐户.
除了让Facebook SDK实际为用户返回电子邮件之外,我已经设置了所有内容.我不知道从哪里开始,可以真正使用一些帮助!
我有以下SQL,我试图对Microsoft SQL Server执行.
$rs = odbc_exec($conn, "INSERT INTO tGuest (`GuestName`, `GuestEmailAddress`, `GuestPassword`, `GuestCity`, `GuestCountry`) VALUES ('test', 'test', 'test', 'test', 'test');");
Run Code Online (Sandbox Code Playgroud)
但是我收到了以下错误:
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '`'.
Run Code Online (Sandbox Code Playgroud)
我看不出SQL代码有什么问题所以我不确定我是否遗漏了某些东西或者有其他错误.
我有以下mysql语句:
INSERT INTO rates_try (`Weight`, `length`, `height`, `Min`, `100`, `200`, `300`) VALUES (1000,0.1,2.3,1,2,3,4);
Run Code Online (Sandbox Code Playgroud)
这给出了错误:
No Row已创建.检查SQL语法中有错误; 检查对应于你的MySQL服务器版本的行1插入到附近使用"insertquery" INTO rates_try正确的语法手册(
Weight,length,height,Min,100,200,300)VALUES(1500,2.31,3.5,1,0,0,0);
表结构是:
rates_try ( `Weight` int(11),
`length` double,
`height` double,
`Min` double,
`100` double,
`200` double,
`300` double )
Run Code Online (Sandbox Code Playgroud)
我不确定语法有什么问题,我知道它很可能与作为数字的列有关,如果这是导致它的问题我将不得不在名称中添加一些东西,所以它们不仅仅是数字,而是我想先检查一下情况并非如此.
这个PHP代码创建了语句
$insertquery = "INSERT INTO rates_{$tablename} (`Weight`, `length`, `height`, `Min`";
foreach ($titles as $title){
if (empty($title) ){
}else{
$insertquery .= ", `" . $title . "`";
$counter++;
} …Run Code Online (Sandbox Code Playgroud) 我需要在活动开始后立即显示一个弹出窗口,但是我最终导致应用程序崩溃,我当前的代码是:
public class GameActivity extends SherlockActivity {
Button firstAnswer;
...
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
...
firstAnswer = (Button) findViewById(R.id.firstanswerbtn);
...
}
protected void onStart() {
super.onStart();
LayoutInflater layoutInflater = (LayoutInflater) getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.playpopup, null);
final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Button play = (Button) popupView.findViewById(R.id.letsplay);
play.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
playRound();
popupWindow.dismiss();
}
});
popupWindow.showAtLocation(firstAnswer, Gravity.CENTER, 0, 0);
}
...
}
Run Code Online (Sandbox Code Playgroud)
但是我最终崩溃了:
12-02 22:27:27.534: E/AndroidRuntime(28142): java.lang.RuntimeException: Unable to …Run Code Online (Sandbox Code Playgroud) 我有以下代码,由于某种原因完全忽略if/else语句中的concats:
returntext = '' +
'<div>' +
'<h4>test ' + profile.id + '">' + profile.name + '</a></h4>' +
'<div class="message-content">' +
message.content +
'</div>'
if (showtrash) {
toadd = '' + '<span class="pull-right small">' + '<a href="#" ><i class="fa fa-trash trash-message"></i></a> ' + '</span>' + '</div>'
returntext.concat(toadd);
} else {
returntext.concat('<span class="pull-right small">' + '</span>' + '</div>');
}
console.log(returntext);
Run Code Online (Sandbox Code Playgroud)
但是,控制台日志只显示returntext等于if/else语句之前的字符串.
做我想要实现的目标的正确方法是什么?谢谢