Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.1djmao:TableView:2.0.4'
}
dependencies {
implementation("com.github.1djmao:TableView:2.0.4")
}
<dependency>
<groupId>com.github.1djmao</groupId>
<artifactId>TableView</artifactId>
<version>2.0.4</version>
</dependency>
libraryDependencies += "com.github.1djmao" % "TableView" % "2.0.4"
:dependencies [[com.github.1djmao/TableView "2.0.4"]]
一个用于 Android 的简单表格控件。参考了 android-tableView 和 TableView 这两个库,使用了其中属性和样式设置类,重写了数据添加方式,添加了点击监听事件。

工程中 build.gradle 文件添加 :
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
module 中 build.gradle 文件中添加(最新版本号查看 releases):
dependencies {
compile 'com.github.1djmao:TableView:LAST_RELEASE'
}
<com.chargemap_beta.android.tableView.library.TableView
android:id="@+id/tableview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tv_data_background_color="@color/md_white_1000" <!-- Background color for data cells -->
app:tv_data_borders_color="@color/md_grey_500" <!-- Borders color for data cells -->
app:tv_header_background_color="@color/md_grey_300" <!-- Background color for header cells -->
app:tv_header_borders_color="@color/md_grey_500" <!-- Borders color for header cells -->
app:tv_scrollingEnabled="false" <!-- Scrolling ? -->
app:tv_padding="8" /> <!-- padding -->
TableView tableView= (TableView) findViewById(R.id.table);
tableView
.setHeader("区域", "人数", "占比")
.addRowContent("北京", "50", "50%")
.addRowContent("上海", "30", "30%")
.addRowContent("广东", "20", "20%")
.addRowContent("深圳", "10", "10%")
.refreshTable();
tableView.setOnTableItemClickListener(new TableView.OnTableItemClickListener() {
@Override
public void itemClickListener(String content, int row, int column) {
Log.i("hhhhh", "itemClickListener: "+content);
}
});