Marquee TextView的不同部分上的Click事件具有不同的意图

时间:2014-04-02 08:10:04

标签: android

我正在开发一个新闻应用,其中突发新闻在选框TextView(单TextView)中滚动。

这意味着TextView中会显示不同的新闻。

当我点击任何新闻时,那时会获取该新闻消息的唯一ID。

有可能吗?如果可能的话。怎么样?请尽快告诉我。

ExpandableListView.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#f4f4f4" >

    <TextView    
            android:id="@+id/marquee_txt"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="@string/marquee"
            android:singleLine="true"
            android:ellipsize="marquee"
            android:focusable="true"
            android:paddingTop="4dp"
            android:freezesText="true"

            android:textSize="20sp"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:textColor="@android:color/white"
            android:textStyle="bold"
            android:background="@color/abs__background_holo_dark" />

            <ExpandableListView
                android:id="@+id/lvExp"
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:background="@drawable/ic_screen"
                />

</LinearLayout>

MainActivity.java

for (int i = 0; i < 5; i++) {

                                Element e = (Element) nlB.item(i);
                               // String aa=parser.getValue(e,KEY_POSTID);
                               // String a11=parser.getValue(e,KEY_TITLE);

                                //breakingnews.put(a11, parser.getValue(e,KEY_TITLE));
                               if(i==0){
                                breaknews = " " + parser.getValue(e, KEY_POSTID);
                                breaknews = breaknews + " : " + parser.getValue(e, KEY_TITLE);
                                breaknews= breaknews + "@#$";
                                //System.out.println("breaknews in if " + breaknews);
                                }else if(i!=0){
                                breaknews = breaknews + parser.getValue(e, KEY_POSTID);
                                breaknews = breaknews + " : " + parser.getValue(e, KEY_TITLE) + "@#$";
                                System.out.println("breaknews in after if " + breaknews);
                                }
                            }


protected void onPostExecute(Void result) {
                try {
                    super.onPostExecute(result);
                    listAdapter = new ExpandableListAdapter(getActivity(), listDataHeader, headerChild, expListView);
                    expListView.setAdapter(listAdapter);
                     if (prog.isShowing()) {
                            prog.dismiss();
                            expListView.setBackgroundColor(0xFFFFFFFF);



                            marquee.setText("Breaking News :" + breaknews);
} catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }               
         }       
    }

0 个答案:

没有答案