我已经搜索了StackOverflow一段时间了,但我只是想确保......
我刚刚擦了笔记本电脑,并备份了我的所有文件.我备份了我的android.jks文件,它又回来了.当我尝试生成一个签名的APK时,它给了我每个人都得到的同样可怕的错误:
Error:Execution failed for task ':app:packageRelease'.
> Failed to read key conjugationappkey from store
"/Users/wasimsandhu/android.jks": Cannot recover key
Run Code Online (Sandbox Code Playgroud)
我有我的android.jks,密钥密码,密钥存储密码.一切都是正确的.我错过了什么?我备份了所有文件,所以如果有我需要的特定文件,我可以找到它,但我不知道该怎么做......
如果我没有任何意义,请让我澄清一下.谢谢!
我正在尝试为我的应用程序添加一个夜间主题,我浪费了将近三个小时,只是试图让我的导航抽屉中的文本和图标变为白色以及深色背景.下面是我想要去了解在这样的方式onCreate()中MainActivity.java:
navigationView = (NavigationView) findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
// This method will trigger onItemClick of navigation menu
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
// Checking if the item is in checked state or not, if not make it in checked state
if (menuItem.isChecked())
menuItem.setChecked(false);
else menuItem.setChecked(true);
if (nightMode == 0) {
SpannableString spanString = new SpannableString(menuItem.getTitle().toString());
spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); // fix the color to white
menuItem.setTitle(spanString);
}
Run Code Online (Sandbox Code Playgroud)
该nightMode布尔是无关紧要,因为它的工作原理.当夜间模式设置为开(0)时,导航抽屉中选择的任何菜单项都将变为白色.然而,这仅在选择每个项目时才会发生,这显然是不方便的.这是我的drawer_dark.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu …Run Code Online (Sandbox Code Playgroud) 好的,我现在已经经历了几个StackOverflow帖子,但我仍然对我工具栏的xml的位置感到困惑.
<android.support.v7.widget.Toolbar
android:id=”@+id/my_awesome_toolbar”
android:layout_height=”wrap_content”
android:layout_width=”match_parent”
android:background=”@styles/colorPrimary” />
Run Code Online (Sandbox Code Playgroud)
它会进入我的/layout/activity_main.xml吗?
这是对这篇文章的一种后续或补充.我试图在我的RecyclerView中获取项目的位置,但我尝试过的方法都没有.
我getAdapterPosition()在PersonViewHolder构造函数中调用并将其值赋给整数位置,该位置在UnitOneFragment类中用于相应地执行某些操作(请参阅onClick()方法).但无论如何,它都不会发生,我的猜测是因为该getAdapterPosition()方法不起作用或未正确使用.
我的适配器:
public class RVAdapter extends RecyclerView.Adapter<RVAdapter.PersonViewHolder> {
Context mContext;
RVAdapter(Context context, List<Chapter> chapters) {
mContext = context;
this.chapters = chapters;
}
public static CardView cv;
public static int position;
public static String chapterNumberTitle;
public class PersonViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
TextView chapterName;
TextView chapterNumber;
// ImageView chapterPhoto;
public PersonViewHolder(View itemView) {
super(itemView);
cv = (CardView) itemView.findViewById(R.id.cv);
chapterName = (TextView) itemView.findViewById(R.id.chapter_name);
chapterNumber = (TextView) itemView.findViewById(R.id.chapter_number);
// …Run Code Online (Sandbox Code Playgroud) android android-support-library android-cardview android-recyclerview
我试图让Toolbar我的应用程序隐藏和显示基于RecyclerView滚动.这个gif显示了我想要实现的目标.
我正在按照本教程而不是得到我正在寻找的结果.这是我的活动布局:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:fitsSystemWindows="true">
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" />
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header"
app:menu="@menu/drawer" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是
Toolbar布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="@color/ColorPrimary"
app:layout_scrollFlags="scroll|enterAlways" />
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,Toolbar完全消失.怎么了?
这是我得到的错误,这个错误似乎与我在StackOverflow上搜索的内容无法解决.
Error:A problem was found with the configuration of task ':checkDebugManifest'.
> File '/Users/wasimsandhu/AndroidStudioProjects/Conjugation/src/main/AndroidManifest.xml'
specified for property 'manifest' does not exist.
Run Code Online (Sandbox Code Playgroud)
每次重建项目或同步Gradle文件时,我都会收到此错误.我在其他各种线程中尝试过解决方案无济于事.
这是我的app/build.gradle文件:
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
// removed for this post
}
}
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.wsandhu.conjugation"
minSdkVersion 15
targetSdkVersion 19
versionCode 1
versionName "0.5"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.+'
compile …Run Code Online (Sandbox Code Playgroud) 我试图在RecyclerView滚动条上隐藏我的工具栏,到目前为止它似乎已经隐藏了,但是它留下了一个白色的空白.我很确定这与我的MainActivity的布局和FrameLayout中的片段的叠加有关.

这是我的activity_main.xml.我需要FrameLayout,因为我在导航抽屉中选择了一个项目来加载不同的片段.
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="7dp"
tools:context=".MainActivity"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/header"
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
这里是片段中包含RecyclerView的代码.
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_main, container, false);
getActivity().setTitle("Unit One");
rv = (RecyclerView) v.findViewById(R.id.rv);
rv.setHasFixedSize(true);
llm = new LinearLayoutManager(getActivity());
rv.setLayoutManager(llm);
initializeData();
initializeAdapter();
rv.addOnScrollListener(showHideToolbarListener = new RecyclerViewUtils.ShowHideToolbarOnScrollingListener(MainActivity.toolbar)); …Run Code Online (Sandbox Code Playgroud) 我一直在谷歌搜索一段时间,但我找不到任何可以解决我的问题的东西。我在嵌套片段类中有一些代码,如下所示:
String infinitive;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
// Grabs input from text field and places it in String infinitive
final EditText mMainTextField = (EditText) rootView.findViewById(R.id.mainTextField);
infinitive = mMainTextField.getText().toString();
final Button mConjugateButton = (Button) rootView.findViewById(R.id.conjugateButton);
mConjugateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean isEndingAr = infinitive.endsWith("ar");
boolean isEndingEr = infinitive.endsWith("er");
boolean isEndingIr = infinitive.endsWith("ir");
// Check to see what kind of verb it is before conjugating
if …Run Code Online (Sandbox Code Playgroud) 当我运行我的应用程序时,MainFragment根本没有显示在扩展ActionBarActivity的活动中.我确实查过这篇文章,但它没有帮我解决我的问题.这是我的活动和片段:
activity_main.xml中:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new MainFragment())
.commit();
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// …Run Code Online (Sandbox Code Playgroud) 假设我有一个字符串,我想将该字符串中的第一个"a"更改为"e"以获得正确的拼写.
let animal = "elaphant"
Run Code Online (Sandbox Code Playgroud)
使用stringByReplacingOccurrencesOfString()会将该字符串中的每个"a"更改为"e",返回:
elephent
Run Code Online (Sandbox Code Playgroud)
我试图得到第一个"a"的索引,然后使用替换它replaceRange(),如下所示:
let index = animal.characters.indexOf("a")
let nextIndex = animal.startIndex.distanceTo(index!)
animal = animal.replaceRange(animal.startIndex.advancedBy(nextIndex)..<animal.startIndex.advancedBy(1), with: "e")
Run Code Online (Sandbox Code Playgroud)
但是,此代码给出了以下错误:
Cannot assign value of type '()' to type 'String'
Run Code Online (Sandbox Code Playgroud)
我一直试图找到一种方法将nextIndex转换为a Int,但我觉得我的整个方法都错了.救命?