【发布时间】:2020-05-13 14:18:58
【问题描述】:
您好,我需要在 TextView 中识别 mParent,确切地说是 CardView 和 RelativeLayout
我需要通过CardView和RelativeLayout的片段插入SQLite数据,其中包含许多CardView;所以我需要确定数据属于哪个布局或CardView数据,以便创建一个插入它们的循环。
我需要CardViewname 和RelativeLayoutname
【问题讨论】:
-
嗨墨西哥人;有一个
getParent()方法可以获取父视图 -
layout = getParent().toString ,这个结果是:android.widget.RelativeLayout{2371e4d VE..... ......ID 0,0-0,0 #7f0a0133 app :id/relap1},我需要名字 relap1
-
你需要父布局的id吗?
-
是的,我需要textview来自的布局名称,
-
你可以从带有
R.id.xx的布局中获取它,就像TextView本身的ID一样对吗?
标签: android sqlite textview fragment