私は初心者で、この問題を解決する必要があります。
09-29 11:53:50.539: E/AndroidRuntime(658): FATAL EXCEPTION: main
09-29 11:53:50.539: E/AndroidRuntime(658): java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
09-29 11:53:50.539: E/AndroidRuntime(658): at com.example.listactivity.MainActivity$MyCustomAdapter$1.onClick(MainActivity.java:91)
09-29 11:53:50.539: E/AndroidRuntime(658): at android.view.View.performClick(View.java:3511)
09-29 11:53:50.539: E/AndroidRuntime(658): at android.view.View$PerformClick.run(View.java:14105)
09-29 11:53:50.539: E/AndroidRuntime(658): at android.os.Handler.handleCallback(Handler.java:605)
09-29 11:53:50.539: E/AndroidRuntime(658): at android.os.Handler.dispatchMessage(Handler.java:92)
09-29 11:53:50.539: E/AndroidRuntime(658): at android.os.Looper.loop(Looper.java:137)
09-29 11:53:50.539: E/AndroidRuntime(658): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-29 11:53:50.539: E/AndroidRuntime(658): at java.lang.reflect.Method.invokeNative(Native Method)
09-29 11:53:50.539: E/AndroidRuntime(658): at java.lang.reflect.Method.invoke(Method.java:511)
09-29 11:53:50.539: E/AndroidRuntime(658): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-29 11:53:50.539: E/AndroidRuntime(658): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-29 11:53:50.539: E/AndroidRuntime(658): at dalvik.system.NativeStart.main(Native Method)
私のmainactivity.java
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View row = inflater.inflate(R.layout.row, parent, false);
TextView textview = (TextView) row.findViewById(R.id.tvTop);
ImageView imageview = (ImageView) row
.findViewById(R.id.list_image);
textview.setText(data_topText[position]);
imageview.setImageResource(data_image[position]);
row.setOnClickListener(new OnClickListener() {
public void onClick(View convertView) {
String product = ((TextView) convertView).getText().toString();
Intent i = new Intent(getApplicationContext(),
SecondScreenActivity.class);
i.putExtra("name", product);
startActivity(i);
}
});
return (row);