答案 0 :(得分:0)
EditText的xml中有一个属性
android:drawableLeft="@drawable/yoursearchIcon"
您可以使用想要搜索的图标在EditText的xml中使用它。要使用默认搜索图标,请使用android.drawable ....
访问它答案 1 :(得分:0)
声明一个菜单项: -
public int dijkstra(){
boolean[] visited = new boolean[gSize];
int src = 1;
int dest = 1;
int[] distance = new int[5];
int[] part = new int[5];
int min;
int nextNode = 0;
for(int i = 0; i < 5; i++)
{
visited[i] = false;
part[i] = 0;
for(int j = 0; j < 5; j++)
if(arr[i][j] == -1)
arr[i][j] = 999; //gives it a high value to ignore
}
distance = arr[src];
distance[src] = 0;
visited[src] = true;
for(int i = 0; i < 5; i++)
{
min = 999;
for(int j = 0; j < 5; j++)
if(min > distance[j] && visited[j] != true)
{
min = distance[j];
nextNode = j;
}
visited[nextNode] = true;
for(int k = 0; k < 5; k++)
if(visited[k] != true)
if(min + arr[nextNode][k] < distance[k])
{
distance[k] = min + arr[nextNode][k];
part[k] = nextNode;
}
}
return distance[dest];
}
在onCreateOptionsMenu方法中: -
<item android:id="@+id/action_search"
android:title="Search"
android:icon="@drawable/abc_ic_search_api_mtrl_alpha"
app:showAsAction="ifRoom|collapseActionView"
app:actionViewClass="android.support.v7.widget.SearchView" />