Skip to content

Commit

Permalink
fix for same id lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
QAutomatron committed May 22, 2019
1 parent 4e4a7d8 commit 5344227
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ElementMatcherTest {
@JvmField
val activityRule = ActivityTestRule(MainActivity::class.java)

private val element = Element(first(withId(R.id.sameId)))
private val element = Element(first(withId(R.id.sameId1)))

@Test
fun should_get_first_element() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
parentLinearLayout = findViewById(R.id.parent_layout)

// Set same id for texts
val sameIdText2 = findViewById<TextView>(R.id.sameId2)
sameIdText2.id = R.id.sameId1
}

fun changeText(view: View) {
Expand Down
12 changes: 8 additions & 4 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@
<TextView
android:text="Text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="163dp"
tools:layout_editor_absoluteX="176dp" android:id="@+id/sameId"/>
android:layout_height="wrap_content"
android:id="@+id/sameId1" app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="163dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="176dp" android:layout_marginStart="176dp"/>
<TextView
android:text="Text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" tools:layout_editor_absoluteY="162dp"
tools:layout_editor_absoluteX="246dp" android:id="@+id/sameId"/>
android:layout_height="wrap_content"
android:id="@+id/sameId2" app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="162dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginLeft="246dp" android:layout_marginStart="246dp"/>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 5344227

Please sign in to comment.