我的gradle文件:
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.skripsi.irwanto.paud"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProauardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.11
}
Run Code Online (Sandbox Code Playgroud)
我明白了 Warning:Unable to find optional library: org.apache.http.legacy
在Kotlin,假设,我有课:
class MyKotlinClass {
lateinit var field: String
}
Run Code Online (Sandbox Code Playgroud)
根据文件:
延迟初始化的属性也作为字段公开.该字段的可见性将与lateinit属性设置器的可见性相同.
我可以在java代码中使用myKotlinClass.field或myKotlinClass.getField().我想禁用字段访问,只保留通过getter和setter访问.
我怎样才能实现这一目标并保持延迟修饰?
以下是我从android下载文件的android代码.
private String executeMultipart_download(String uri, String filepath)
throws SocketTimeoutException, IOException {
int count;
System.setProperty("http.keepAlive", "false");
// uri="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTzoeDGx78aM1InBnPLNb1209jyc2Ck0cRG9x113SalI9FsPiMXyrts4fdU";
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
int lenghtOfFile = connection.getContentLength();
Log.d("File Download", "Lenght of file: " + lenghtOfFile);
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(filepath);
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress("" + (int) ((total * 100) / lenghtOfFile));
output.write(data, 0, count); …Run Code Online (Sandbox Code Playgroud) 显示了框架 7 中的本机选择和智能选择选择器,但当我单击它们时,没有任何内容打开。这是我尝试过的一个示例,我可以看到下拉菜单,但是当我单击它时什么也没有发生:
<select name="car">
<option value="mercedes">Mercedes</option>
<option value="bmw">BMW</option>
<option value="volvo">Volvo</option>
<option value="vw" selected="">Volkswagen</option>
<option value="toyota">Toyota</option>
<option value="cadillac">Cadillac</option>
<option value="nissan">Nissan</option>
<option value="mazda">Mazda</option>
<option value="ford">Ford</option>
<option value="chrysler">Chrysler</option>
<option value="dodge">Dodge</option>
</select>
Run Code Online (Sandbox Code Playgroud)
有什么在 Android Web 视图上运行良好的下拉组件的建议吗?
android webview android-layout android-webview drop-down-menu
假设我的布局类似于:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/bottomIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:src="@drawable/some_image"
app:layout_anchor="@+id/bottomNavigation"
app:layout_anchorGravity="top|center"/>
<some.widget.SomeView
android:id="@+id/bottomView"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
一切都很好,bottomIcon放在上面bottomView.当我尝试翻译bottomView一点时,一切仍然是好的,bottomIcon也被翻译了.
但是,当我尝试bottomView从屏幕上翻译下来时:
public void slideOut(View view) {
view.animate()
.translationY(500) //example constant
.start();
}
//then somewhere call
slideOut(bottomView)
Run Code Online (Sandbox Code Playgroud)
然后bottomView移出屏幕bottomIcon,直到它达到CoordinatorLayout的下限.然后bottomIcon不要向下移动.
bottomIcon即使锚点离开屏幕,我怎样才能实现锚定视图()跟随其锚点('bottomView')?(解决方案越简单越优越好)
最近我遇到了一个问题,通过十进制步骤迭代十进制数字,我很想知道,为什么Kotlin只有进步Int,Long而且Char.
我明白,可能会有一些带小数的警告.但仍然.我们只想要一个起始BigDecimal编号,结束BigDecimal编号,然后用BigDecimal步骤迭代它们.
问:那么,为什么整数不存在任何进展?谢谢.
PS:这是一个可能实现的示例代码(我为Int采用了源代码并进行了调整BigDecimal):
/**
* Returns a progression that goes over the same range with the given step.
*/
public infix fun BigDecimalProgression.step(step: BigDecimal): BigDecimalProgression {
if (step <= java.math.BigDecimal.ZERO) throw IllegalArgumentException("Step must be positive, was: $step.")
return BigDecimalProgression.fromClosedRange(first, last, if (this.step > java.math.BigDecimal.ZERO) step else -step)
}
/**
* A progression of values of type `BigDecimal`.
*/
public open class …Run Code Online (Sandbox Code Playgroud) E /项目位置:29
E /项目Rv:15
E/Child适配器:30
public class MainActivity extends Activity {
RecyclerView reView;
ArrayList<RvModel> rvModels;
revAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
reView = (RecyclerView) findViewById(R.id.reView);
reView.setLayoutManager(new GridLayoutManager(MainActivity.this, 3));
rvModels = new ArrayList<>();
adapter = new revAdapter(MainActivity.this, rvModels);
reView.setAdapter(adapter);
prepareData();
reView.addOnItemTouchListener(new RecyclerItemClickListener(MainActivity.this, reView, new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Log.e("Item Pos", "" + position);
Log.e("Item Rv", "" + reView.getChildCount());
Log.e("Child Adapter", "" + …Run Code Online (Sandbox Code Playgroud) 最近,我惊讶于一个问题。在我的android手机上,具有相同高度的列表或滚动视图的元素具有与其位置相关的不同阴影。例如,每当屏幕底部的视图具有更暗和更强的阴影时,屏幕顶部的视图将具有较小的光影。这是Google Keep应用程序的屏幕截图:
因此,我认为这完全是因为Google Keep应用程序。也许Google的家伙决定为他们的应用程序添加阴影。因此,我创建了一个示例应用程序。
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
<TextView
style="@style/AppButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Test"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的风格:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item …Run Code Online (Sandbox Code Playgroud) 目前我通知用户 -
mNotificationManager.notify("My App Name",1212,notification);
Run Code Online (Sandbox Code Playgroud)
这很好用.但它在状态栏中只显示一个图标,但我在不同时间发送了多个通知.
我想为每个通知显示图标(即3个图标).
我不确定是否可能.任何线索?