如何从行中获取行号?
假设我有一个像这样的字符串
String testString = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis p";
Run Code Online (Sandbox Code Playgroud)
而且我有一个将显示字符串的视图.在另一种情况下,我想在渲染之前先获取行号.
我想从Android中获取此字符串中的行号.我有几种方法可以获得行号.但在每个解决方案中,我们都可以在视图渲染后获取行号.但是在渲染视图之前我想要它.我想得到20个或更多不同字符串的行号.
我怎么能得到这个想法?
当我尝试运行我的项目时遇到了这个问题 -
com.android.builder.dexing.DexArchiveBuilderException:无法处理.gradle \缓存\变换-1 \文件-1.1 \火力-分析-IMPL-11.8.0.aar \ 0e3311be69809df8820438f9666651f5 \罐子\ classes.jar
com.android.builder .dexing.DexArchiveBuilderException: dexing 时出错。
com.android.tools.r8.CompilationFailedException:编译未能完成 com.android.tools.r8.utils.AbortException:错误:类型 com.google.android.gms.common.internal.zzf 被引用为来自com.google.android.gms.internal.zzcku.引起:com.android.builder.dexing.DexArchiveBuilderException:无法处理 Firebase-analytics-impl-11.8.0.aar\jars\classes.jar
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xxxxxx.xxxx"
minSdkVersion 17
targetSdkVersion 28
versionCode 171312
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
project.archivesBaseName = "doctor"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
debug {
minifyEnabled false
proguardFiles fileTree(dir: "proguard", include: ["*.pro"]).asList().toArray()
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
} …Run Code Online (Sandbox Code Playgroud) 所以,我下载的Android应用程序的教程告诉我一切,我和使用Eclipse,但我一直收到错误消息main在R.menu.main:
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;
Run Code Online (Sandbox Code Playgroud)
我已经导入了android.R;它并没有用; 我删除了那一行,然后我去了Project> Clean,它仍然没有自行修复.关于这个主题的其他人一直在说从你的包中导入"R文件",但我检查了所有的包和类,没有任何调用R.我尝试导入该res文件夹,但也无法正常工作.救命?
我的应用程序崩溃了
由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'尝试将同一索引路径的多个单元格出列,这是不允许的.如果您确实需要出现比表视图请求更多的单元格,请使用-dequeueReusableCellWithIdentifier:方法(不带索引路径).
当我尝试重新加载我的单个单元格时tableView,这是我按下以重新加载单元格的按钮
@IBAction func reloadCell(_ sender: UIButton) {
let index = IndexPath(row: sender.tag, section: 0)
self.tableView.reloadRows(at: [index], with: .right)
}
Run Code Online (Sandbox Code Playgroud)
这些是我的cellForRow和DidSelectRow
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: resueIdentifier, for: indexPath) as! MyTableViewCell
cell.delegate = self
cell.myCellNumber.text = "\(indexPath.row + 1)"
cell.refButton.tag = indexPath.row
cell.refButton.addTarget(self, action: #selector(CourseClass2.reloadCell(_:)), for: .touchUpInside)
let place = sortedArray[indexPath.row]
cell.update(place: place)
cell.selectionStyle = .none
if indexPath.row == places.count - 1 {
loadPlaces(false) …Run Code Online (Sandbox Code Playgroud) 我是 Android 开发的新手。我按照本教程进行了显示ExpandableListView及其正常工作。如果我按所有组,则所有组都会扩展。
我想一次只扩展一组。一开始,第一个组会自动展开,如果我点击另一个组,则第一个组将折叠,最近的组将展开。是否可以?
如果可能的话,我怎样才能得到。有什么建议吗?
我正在我的.IRecyclerview中使用我的 RecyclerView 类。我需要在我编写的一种方法中显示。但我收到一个错误FragmentAdapterAlertDialogAdapterClass
android.app.Activity 无法应用于 android.content.Context。
这是我的代码AlertClass
public class AlertClass {
public void noInternetAlert(Activity activity)
{
final AlertDialog alertDialog=new AlertDialog.Builder(activity).create();
AlertDialog.Builder builder=new AlertDialog.Builder(activity);
builder.setTitle("No Internet Connection");
builder.setMessage("You need to have Mobile data or Wifi to access this.");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
alertDialog.cancel();
}
});
builder.show();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的方法的代码AdapterClass
private void free() {
AlertClass alert=new AlertClass();
alert.noInternetAlert(context);
}
Run Code Online (Sandbox Code Playgroud)
这是适配器类的代码
public class BusyAdapter extends RecyclerView.Adapter<BusyAdapter.ViewHolder>
{ …Run Code Online (Sandbox Code Playgroud) android android-context android-fragments android-dialog android-recyclerview
我想将一个动作附加到键盘上的按钮。我不想创建自定义键盘,只处理搜索/执行/完成按钮操作。

谢谢!
我正在RecyclerView与Grid layout. 一切正常。但我需要在水平中心设置列。例如。我有 18 个项目,跨度数为 4。对于最后一行,我有 2 个项目。这两个项目应该在水平中心而不是左边。
这是我的RecyclerView:
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
android:layout_gravity="center_horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rv_answer" />
Run Code Online (Sandbox Code Playgroud)
这是我的adapter layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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_marginStart="@dimen/marginVSmall"
android:layout_marginEnd="@dimen/marginVSmall"
android:layout_marginTop="@dimen/marginVSmall"
android:layout_marginBottom="@dimen/marginVSmall"
android:layout_height="wrap_content">
<curvegraph.com.vijay.widgets.SquareTextView
android:id="@+id/tv_option"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/circle"
android:gravity="center"
android:text="A"
android:textStyle="bold"
android:maxLength="1"
android:textColor="@color/colorWhite"
android:textSize="@dimen/textXLarge"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5" />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
我要设置的 Kotlin 代码 LayoutManager
rv_option.layoutManager = GridLayoutManager(this, 4)
Run Code Online (Sandbox Code Playgroud)
这是我的 Kotlin 代码:
val grid = GridLayoutManager(this, 8)
grid.spanSizeLookup = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在下面的链接上完成相同的查询,但是这里没有运气:
https://dzone.com/articles/get-last-record-in-each-mysql-group
您能否建议将上述链接上的原始查询转换为sequelize ORM格式的正确方法?
我有一个包含许多字段的对象.例:
房子
- 窗户
- 门
- 管道
等
我正在寻找一种优雅的方法来检查其中一个元素是否为空.代替 -if (windows != null || doors != null || pipes...)