Я новый разработчик в android.i создал класс представления в этом классе представления. Я хотел бы применить значения массива строк к textview, мой класс представления выглядит следующим образом:
class MyView extends View
{
Context con;
String messages[]=new String[]{"hello","hai","how are you","where are you"};
public MyView(Context context) {
super(context);
con=context;
for(int i=0;i<3;i++)
{
Log.v("messages", "messages"+messages[i]);
}
public View getView(int position, View view, ViewGroup vg)
{
if (view == null)
{
// context would be a variable set via the constructor and given
// by our owner (most likely a ListActivity)
LayoutInflater inflater = (LayoutInflater)con.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.view, null);
}
// Here you would get the sub-views of your layout and fill them
TextView msg = (TextView) view.findViewById(R.id.txtmessage);
msg.setText(messages[position]);
return view;
}
}
из приведенного выше класса я хотел бы просмотреть представление класса MyView в классе активности
public class ViewActivity extends Activity {
TableRow tbr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view);
tbr=(TableRow)findViewById(R.id.tableRow1);
MyView mv=new MyView(this);
tbr.addView(mv);
}
}
из приведенного выше кода я не могу просмотреть класс MyView
как я могу получить представление о классе MyView