简体   繁体   中英

getting class type in eclipse template

I'm learning to make snippets for eclipse. My idea was to make something to make quick findViewByIds, so when you declare a var the snippet gets the type and the name of the var and writes the rest of the code.

If you write

Button myButton findView

The snippet should get the Class (Button) and the name (myButton) and write:

= (Button) findViewById(R.id.myButton);

Im doing good but i cant get the Button class. Any help? My code is

= ($type)findViewById(R.id.${name:var});
${cursor}

您应该尝试这样:

${type} ${new_name} = (${type})findViewById(R.id.${name});${cursor}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM