首页 \ 问答 \ 如何以编程方式获取android.R.id.content的资源ID?(How to programmatically get resource Id for android.R.id.content? [duplicate])

如何以编程方式获取android.R.id.content的资源ID?(How to programmatically get resource Id for android.R.id.content? [duplicate])

这个问题在这里已有答案:

我正试图在图书馆项目中这样做......

int containerViewId = getResources().getIdentifier("content", "android.R.id", getPackageName());

getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();

但是我在替换上得到了这个异常:引起:java.lang.IllegalArgumentException:必须使用非零的containerViewId

如何以编程方式获取android.R.id.content的资源ID?

谢谢。

编辑:我已经通过使用命名视图解决了它,在活动的xml布局中设置id并使用以下代码替换根视图...

int containerViewId = getResources().getIdentifier("rootView", "id", getPackageName());
getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();

This question already has an answer here:

I'm trying to do this in a library project...

int containerViewId = getResources().getIdentifier("content", "android.R.id", getPackageName());

getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();

But I get this exception on the replace: Caused by: java.lang.IllegalArgumentException: Must use non-zero containerViewId

How do I get resource id for android.R.id.content programmatically?

Thanks.

Edit: I have solved it by using a named view, setting the id in the xml layout of the activity and using the following code to replace the root view...

int containerViewId = getResources().getIdentifier("rootView", "id", getPackageName());
getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();

原文:https://stackoverflow.com/questions/21841918
更新时间:2022-06-02 15:06

最满意答案

create table table1(tem varchar2(50), tablename varchar2(50));
create table tabl2(tabl_name varchar2(50));

insert into table1(tem, tablename) values ('table1','table1');

begin
  for rc in (select tablename from table1) loop
     --dbms_output.put_line('insert into tabl2(tabl_name) (select ''tem'' from '||rc.tablename||')');
     execute immediate 'insert into tabl2(tabl_name) (select ''tem'' from '||rc.tablename||')' ;    
  end LOOP; 
end;

create table table1(tem varchar2(50), tablename varchar2(50));
create table tabl2(tabl_name varchar2(50));

insert into table1(tem, tablename) values ('table1','table1');

begin
  for rc in (select tablename from table1) loop
     --dbms_output.put_line('insert into tabl2(tabl_name) (select ''tem'' from '||rc.tablename||')');
     execute immediate 'insert into tabl2(tabl_name) (select ''tem'' from '||rc.tablename||')' ;    
  end LOOP; 
end;

相关问答

更多
  • 简单。 布尔代数。 SELECT issueDate Date_Time, firstName, player_id Player_ID FROM PlayerNote pn join Brand b WHERE (curdate()='2016-12-18' and pn.issueDate >= date_format(date_sub(curdate(),interval 1 month), '%Y-%m-01') and pn.issueDate ...
  • 传递给存在测试的路径中的空间使解析器混乱。 通常,您应该在这些名称周围加上引号。 IF EXIST "C:\Program Files (x86)\Google\Chrome" ( start chrome www.google.com ) ELSE ( start iexplore www.google.com ) The space in the path passed to the exist test is confusing the parser. In general you shoul ...
  • [BeforeScenarioBlock]将在场景中的任何“块”之前运行,即在每个单独的Given , When或Then块之前运行。 没有内置的方法来指定钩子应该只在特定类型的块之前运行我不认为但是我认为它应该足够直接以确保代码仅在钩子代码内的特定块之前运行。 像这样的东西: [BeforeScenarioBlock] public void BeforeScenarioBlock() { if (ScenarioContext.Current.CurrentScenarioBlock == Sc ...
  • 您不应该在click函数中重新定义resizeValue变量。 只需从var resizeValue删除var (它只应在var resizeValue的顶部使用)。 You shouldn't redefine the resizeValue variable within the click function. Just remove var from var resizeValue (it should only be used at the top of the ready-function).
  • 您错过了查询中'filePathName'的单引号: Query query = sessionDao.getSession().createSQLQuery("update DeputeAppeal set FilePath=" + filePathName + " where id=" + deputeAppeal.getId()); 改为使用它: Query query = sessionDao.getSession().createSQLQuery("update DeputeAppeal set ...
  • 看起来path是一个标签而不是一个函数。 如果它是一个函数,你可以像这样使用它: {% path(file, 'reference') %} 相比之下,Twig具有函数dump ,而在Symfony中,可以使用具有相同名称的标记。 以下是你如何使用它们的方法: {{ dump(foo) }} {# function #} {% dump foo %} {# tag #} 你看到区别? 如果path是一个函数,这两个可能是可能的: {{ file.name ?: path(file, 'referenc ...
  • put this code and also include your Jquery file -(dont forget) echo ""; put this code and also include your Jquery file -(dont forget) echo "