[英]How do I resolve red filenames with Android if I can't find any issues?
Problem: I cannot seem to resolve the red filenames within my project despite doing the common fixes.问题:尽管进行了常见修复,但我似乎无法解析项目中的红色文件名。
What I was trying to do: I had existing functionality in another project, as in one class
and one activity
, that I copied to this project rather than recreating them.我正在尝试做的事情:我在另一个项目中拥有现有功能,例如在一个
class
和一个activity
中,我将其复制到该项目而不是重新创建它们。
What I have tried: I have fixed some issues and warnings that were identified or apparent.我尝试过的:我已经修复了一些已识别或明显的问题和警告。 I included the new activity in the
androidmanifest.xml
, corrected import
and package
statements, etc. I continued with searching here and elsewhere.我在
androidmanifest.xml
中包含了新活动,更正了import
和package
语句等。我继续在这里和其他地方搜索。 I tried suggestions such as, invalidating caches and restarting, running an analysis on each file for errors or issues, and simply committed to git (VCS).我尝试了一些建议,例如,使缓存无效并重新启动,对每个文件运行分析以查找错误或问题,并简单地提交给 git (VCS)。 Some similar posting went unresolved like on JetBrains, which the first response was to commit to VCS.
一些类似的帖子在 JetBrains 上没有得到解决,第一反应是提交给 VCS。 Some suggestions were to make changes in
Settings
but I really felt that was a workaround and not a solution.一些建议是在
Settings
中进行更改,但我真的觉得这是一种解决方法,而不是解决方案。
activity layout活动布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivityMaster">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_enter_db" />
<EditText
android:id="@+id/database_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="@string/master_enter_db"
android:hint="@string/master_enter_db"
android:inputType="text"
android:text="">
</EditText>
<Button
android:id="@+id/addDatabase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_add_db">
</Button>
<ListView
android:id="@+id/database_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ListView>
<Button
android:id="@+id/useSelectedDatabase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_no_db_selected"
android:clickable="false"
>
</Button>
</LinearLayout>
Activity Class活动 Class
public class MainActivityMaster extends AppCompatActivity {公共 class MainActivityMaster 扩展 AppCompatActivity {
MasterDatabase mMasterDB;
MasterDao mMasterDBDao;
EditText mDBToAdd;
Button mAddDB,mUseSelectedDatabase;
ListView mDatabaseList;
SimpleCursorAdapter mSCA;
Cursor mCsr;
long mSelectedDatabaseId = 0;
String mSelectedDatabaseName = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_master);
mDBToAdd = this.findViewById(R.id.database_name);
mAddDB = this.findViewById(R.id.addDatabase);
mUseSelectedDatabase = this.findViewById(R.id.useSelectedDatabase);
mDatabaseList = this.findViewById(R.id.database_list);
mMasterDB = MasterDatabase.getInstance(this);
mMasterDBDao = mMasterDB.getMasterDao();
setUpAddDBButton();
setUpUseSelectedDatabaseButton();
setOrRefreshDatabaseList();
}
private void setUpAddDBButton() {
mAddDB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mDBToAdd.getText().toString().length() > 0) {
if (mMasterDBDao.insert(new MasterDatabaseList(mDBToAdd.getText().toString())) > 0) {
mDBToAdd.setText("");
setOrRefreshDatabaseList();
}
}
}
});
}
private void setUpUseSelectedDatabaseButton() {
mUseSelectedDatabase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mSelectedDatabaseId > 0) {
Intent intent = new Intent(view.getContext(),MainActivity.class);
intent.putExtra(MainActivity.INTENT_EXTRA_DATABASEID, mSelectedDatabaseId);
intent.putExtra(MainActivity.INTENT_EXTRA_DATABASENAME,mSelectedDatabaseName);
startActivity(intent);
}
}
});
}
private void setOrRefreshDatabaseList() {
mCsr = mMasterDBDao.getAllDatabasesAsCursor();
if (mSCA == null) {
mSCA = new SimpleCursorAdapter(
this.getApplicationContext(),
android.R.layout.simple_list_item_1,
mCsr,
new String[]{MasterDatabaseList.COL_DATABASE_NAME},
new int[]{android.R.id.text1},
0
);
mDatabaseList.setAdapter(mSCA);
mDatabaseList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
/* Handle Clicking on an Item (i.e. prepare UseSelected Button) */
@SuppressLint("Range")
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
mSelectedDatabaseId = l;
if (l > 0) {
mSelectedDatabaseName = mCsr.getString(mCsr.getColumnIndex(MasterDatabaseList.COL_DATABASE_NAME));
mUseSelectedDatabase.setText(mSelectedDatabaseName);
mUseSelectedDatabase.setClickable(true);
} else {
mUseSelectedDatabase.setText(R.string.master_no_db_selected);
mUseSelectedDatabase.setClickable(false);
}
}
});
} else {
mSCA.swapCursor(mCsr);
}
}
@Override
protected void onResume() {
super.onResume();
setOrRefreshDatabaseList();
}
@Override
protected void onDestroy() {
super.onDestroy();
mCsr.close();
}
} }
I resolved my issue and it was probably due to being naive on my part.我解决了我的问题,这可能是因为我太天真了。 The files were not being committed because they were not showing as "checked" to be committed.
这些文件没有被提交,因为它们没有显示为“已检查”以提交。 The one caveat to this scenario is that I had never encountered it before because all files I wanted to commit were checked by default, so I didn't see it before.
这种情况的一个警告是我以前从未遇到过它,因为我想提交的所有文件都默认检查,所以我以前没有看到它。 Once I check the box, it committed since there were not other possible "red-filename" issues.
一旦我选中该框,它就会提交,因为没有其他可能的“红色文件名”问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.