小编Mar*_*mes的帖子

Textview选框以编程方式

尝试从数组中填充textview.我通过下面的代码设法通过XML获得了预期的效果

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

    <TextView
        android:id="@+id/marque_scrolling_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:padding="16dp"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="Create a Marquee (Scrolling Text) in Android Using TextView. Android Marquee (Scrolling Text) Tutorial with Example"
        android:textSize="24sp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

但我需要在数组中使用其中的几个 - 所以我认为以编程方式创建文本视图可能是答案,但是无法将它们添加到字幕中.这是我正在努力的代码.

String[] strings = {"Mark", "James", "Paul"};
        LinearLayout layout = (LinearLayout)findViewById(R.id.linearlayout);


        for(String s : strings)
        {
             TextView newTextView = new TextView(this);
             newTextView.setText(s);
             newTextView.setSingleLine(true);
             newTextView.setEllipsize(TextUtils.TruncateAt.END);       
             newTextView.setHorizontallyScrolling(true);
             newTextView.setLines(1);
             newTextView.setMarqueeRepeatLimit(-1);
             newTextView.setSelected(true);  
             newTextView.setTextSize(24);
             layout.addView(newTextView);
        }
Run Code Online (Sandbox Code Playgroud)

android listview marquee textview android-layout

4
推荐指数
2
解决办法
6585
查看次数

Dropdown onchange调用PHP函数

我尝试使用以下代码执行的操作是从下拉菜单中调用PHP函数。

有一种干净的方法吗?

码:

<html>
<head>
</head>
<body>
   <?php
     function OnSelectionChange() {
       echo("OK IT WORKS");
     }    
  ?>
  <section>
    <select onchange="OnSelectionChange()">
      <option value='' disabled selected>Assign Driver</option>
      <option value='4353'>Steve Jobs</option>
      <option value='3333'>Ian Wright</option>
      <option value='66666'>Mark James</option>
    </select>
  </section>    
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

html php select onchange dropdown

3
推荐指数
2
解决办法
5万
查看次数