如何使用elseif部分编写PHP三元运算符?
我看到的基本实施例if
和else
类似这样的PHP三元运算符的部分:
echo (true) ? "yes" : "no"; //prints yes
echo (false) ? "yes" : "no"; //prints no
Run Code Online (Sandbox Code Playgroud)
如何将这样的"elseif"部分输入三元运算符?
<?php
if($result->vocation == 1){
echo "Sorcerer";
}else if($result->vocation == 2){
echo 'Druid';
}else if($result->vocation == 3){
echo 'Paladin';
}else if($result->vocation == 4){
echo 'Knight';
}else if($result->vocation == 5){
echo 'Master Sorcerer';
}else if($result->vocation == 6){
echo 'Elder Druid';
}else if($result->vocation == 7){
echo 'Royal Paladin';
}else{
echo 'Elite Knight';
}
?>
Run Code Online (Sandbox Code Playgroud) 我想整合这样的东西:
我这样做了,但我似乎无法将imageview放在工具栏下面.没有工具栏,我可以在状态栏下进行,但是将这两者结合起来是不可能的.
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context="com.project.android.PhotoActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/photo_tl"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#59000000"
tools:ignore="UnusedAttribute" />
<ImageView
android:id="@+id/photo_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitStart" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在我的活动中,我做了以下事情:
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
我还声明了一个styles-v21.xml文件:
<style name="Project.Photo" parent="Project.Light">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#59000000</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并将其设置为PhotoActivity的默认样式.我已经尝试将工具栏放在FrameLayout中,但这样做我的工具栏只是隐藏,如下所示:
提前致谢.
得到了修复,但工具栏与状态栏重叠.反正有没有修复填充?如果我使用android:fitsSystemWindows ="true",状态栏不再是半透明的.
android android-layout material-design android-toolbar android-statusbar
我正在为游戏开发一个所谓的AAC(自动帐户创建器),它基本上是一个具有为玩家创建帐户,玩家和更多东西的功能的网站.服务器只支持SHA1和plain - 这是完全不安全的.我无法深入了解源代码并进行更改.如果无论如何都要使用SHA1,我将不胜感激.我刚看过BCrypt,它很棒,但我无法真正改变源代码以适应BCrypt.我设法将SHA1放在注册上,如下所示:
$password = $input['password'];
$password = sha1($password);
Run Code Online (Sandbox Code Playgroud)
但我根本无法登录.我做错了吗?好像Laravel不会让我登录.
我有get_register
和post_register
,还有我有get_login
和post_login
.我是否需要在post_login中更改某些内容以使其登录或?任何提示?
我在WAMP上使用Laravel的php服务器(php artisan serve)和phpMyAdmin.我认为Laravel通过Auth::attempt
方法laravel 检查数据库是否正在进行某种形式的哈希来检查当前的pw和登录的一个以检查对方.
private class getArticles extends AsyncTask<Void, Void, Void> {
String url;
getArticles(String paramUrl) {
this.url = paramUrl;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
mProgressDialog = new ProgressDialog(App.this);
mProgressDialog.setMessage("U?itavanje artikala...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
}
@Override
protected Void doInBackground(Void... params) {
arraylist = new ArrayList<>();
try {
Document document = Jsoup.connect(url).get();
Elements els = document.select("ul.category3 > li");
for (Element el : els) {
HashMap<String, String> map = new HashMap<>();
Elements slika = el.select("div.category3-image > a > img");
Elements naslov = el.select("div.category3-text > …
Run Code Online (Sandbox Code Playgroud) 这是我的TimeInterval类:
public class TimeInterval {
private int fTime;
private int sTime;
public TimeInterval(int fTime, int sTime) {
if(fTime < 0 || fTime > 2400 || sTime < 0 || sTime > 2400) {
System.out.println("Illegal times, must be < 2400 and > 0)");
System.exit(0);
} else {
this.fTime = fTime;
this.sTime = sTime;
}
}
public int getHours() {
return Math.abs((fTime - sTime) / 100);
}
public int getMinutes() {
return Math.abs((fTime - sTime) % 100);
}
public double getDecimalTime() { …
Run Code Online (Sandbox Code Playgroud) 如何在导航栏中的按钮之间腾出空间?我通常这样做,
但它现在不起作用.这是一个JSfiddle,它看起来如何:
我从Bootstrap 3.0.3 docs站点复制了bs-example的CSS代码.我是一个CSS初学者,所以如果有人能解释我,我会很感激.
以下代码:
/* Echo out a label for the example */
.bs-example:after {
content: "Example";
position: absolute;
top: 15px;
left: 15px;
font-size: 12px;
font-weight: bold;
color: #bbb;
text-transform: uppercase;
letter-spacing: 1px;
}
Run Code Online (Sandbox Code Playgroud)
它按预期工作,
但我想标题,例子,可以改变.我想使用像我们这样的标签<zd></zd>
.
提前致谢.
我在文本视图中显示我的html数据.在ListView中,它显示原始HTML.
这是图片:
我的文章活动:
package net.biscani.dino;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.widget.TextView;
public class ArticleActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_article);
Intent in = getIntent();
String name = in.getStringExtra(GetArticles.KEY_TITLE);
String content = in.getStringExtra(GetArticles.KEY_CONTENT);
TextView lblName = (TextView) findViewById(R.id.name_label);
TextView lblDesc = (TextView) findViewById(R.id.content_label);
lblName.setText(name);
lblDesc.setText(Html.fromHtml(content));
lblDesc.setMovementMethod(ScrollingMovementMethod.getInstance());
}
}
Run Code Online (Sandbox Code Playgroud)
这也是我的MainActivity:
package net.biscani.dino;
import android.support.v7.app.ActionBarActivity;
import java.util.ArrayList;
import java.util.HashMap;
import net.biscani.dino.ArticleActivity;
import net.biscani.dino.GetArticles;
import net.biscani.dino.MainActivity;
import net.biscani.dino.R;
import android.app.ListActivity;
import android.app.LoaderManager.LoaderCallbacks;
import …
Run Code Online (Sandbox Code Playgroud) 我定义了以下代码,以便能够在特定位置设置文本.
if(position == 0) {
holder.text.setText("blah");
}
Run Code Online (Sandbox Code Playgroud)
我想要检查位置是否等于0,然后如果是,则在位置p上设置文本 - 每次它是p =位置+ 1(下一个位置).我们是否能够将文本从持有者设置为文本视图,但是在某个位置.
谢谢.
android listview android-adapter baseadapter android-viewholder
我基本上想要的是用户权限.
我的数据库中有一个名为'accounts'的表.有一个名为'group_id'的列.我想在'group_id'= 3时设置它,然后用户是admin.然后他可以查看特殊网站,按钮和类似的东西.我试图实现类似的东西:
public function ($roleName) {
$role = $this->roles;
if ($role->name == $roleName) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
此外,我不知道该模型需要什么以及如何,我需要一个新的和类似的东西.